Page 79 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 79

Fundamentals of Data Structures




                    Notes
                                                Figure 5.6: Four parallel arrays, NAME, AGE, SEX and PHONE















                                   Source:  http://www.csbdu.in/econtent/DataStructures/Unit1-DS.pdf


                                          Example:
                                   Consider again the Newborn record in previous example of newborn. One can store a file of
                                   such records in nine linear arrays, such as

                                     NAME, SEX, MONTH, DAY, YEAR, FATHERNAME, FATHERAGE, MOTHERNAME,
                                     MOTHERAGE
                                   one array is for each elementary data item. Here we must use different variable names for the
                                   name and age of the father and mother, which was not necessary in the previous example.
                                   Again, we assume that the arrays are parallel, i.e. that for a fixed subscript K, the elements
                                     NAME[K], SEX[K], MONTH[K],….., MOTHERAGE[K]

                                   belong to the same record.

                                   Records with Variable Lengths

                                   Consider an elementary school keeps a record for each student which contains the following
                                   data: Name, Telephone Number, Father, Mother, Siblings. Here Father, Mother, Siblings contain,
                                   respectively, the names of the student’s father, mother, and brothers or sisters attending the
                                   same school. Three such records may be as follows.

                                   Adams, John;       345-6677;     Richard;    Mary;       Jame,William,Donald
                                   Bailey, Susan;     222-1234;     XXXX;       Sheela;     XXXX
                                   Sami, Mohammed;    567-3344;     Abdul;      Fathima;    Aliya

                                   Here, XXXX means that the parent has died or is not living with the student, or that the student
                                   has no sibling at the school. From the above records, we could learn that they are in variable-
                                   lengths, since the data element Siblings can contain zero or more names.

                                   Self Assessment

                                   Fill in the blanks:
                                   11.  A .................... is a collection of related data items, each of which is called a field or attribute.
                                   12.  The names given to the various data items are called ....................

                                   13.  The data items in a record are indexed by .................... names.





          72                                LOVELY PROFESSIONAL UNIVERSITY
   74   75   76   77   78   79   80   81   82   83   84