Page 76 - DCAP201_FUNDAMENTALS_OF_DATA_STRUCTURES
P. 76

Unit 5: Pointers




          items Month, Day and Year, and Father and Mother are group items, each with sub items Name  Notes
          and Age.
          Let we describe the structure of the above record. (Name appears three times and age appears
          twice in the structure.)
          1    Newborn
               2    Name

               2    Sex
               2    Birthday
                    3    Month
                    3    Day

                    3    Year
               2    Father
                    3    Name
                    3    Age

               2    Mother
                    3    Name
                    3    Age
          The number to the left of each identifier is called a level number. Observe that each group item
          is followed by its sub items, and the level of the sub items is 1 more than the level of the group
          item. Furthermore, an item is a group if and only if it is immediately followed by an item with
          a greater level number.
          Some of the identifiers in a record structure may also refer to arrays of elements. In fact, the first
          line of the above structure is replaced by
          1 Newborn(20)
          This will indicate a file of 20 records, and the usual subscript notation will be used to distinguish
          between different records in the file. That is, we will write to
          Newborn1, Newborn2, Newborn3, . . .
          or
          Newborn[1], Newborn[2], Newborn[3],. . .

          to denote different records in the file.


                 Example:
          A class of student records may be organized as follows:
          1    Student(20)
               2    Name
                    3    Last

                    3    First
                    3    MI (Middle Initial)



                                           LOVELY PROFESSIONAL UNIVERSITY                                   69
   71   72   73   74   75   76   77   78   79   80   81