Page 81 - DCAP407_DATA_STRUCTURE
P. 81
Data Structure
struct Address
{
int Dno;
int Road;
char Area;
}A
}AN1;
If a programming language does not support the hierarchical structures concept, then we can assume
that the record contains non-homogenous data. The record can be stored in individual variables, one for
each of its elementary data items. Suppose you want to store an entire file of records, then such a file
can be stored as a collection of parallel arrays. This means that elements of different arrays with the
same subscript can belong to the same record. The following two examples illustrate this.
Suppose, a health club membership contains the name, age, gender, and telephone
number of each member. Then, you can store the file in four parallel arrays i.e.,
Name, Age, Gender, and Phone as shown below:
Consider the Kindergarten application records example. You can store the file of
such records in twelve linear arrays such as, Name, Gender, Month, Day, Year,
FatherName, FatherAge, MotherName, MotherAge, AddressDno, AddressRoad,
AddressArea; one array for each elementary data item.
Here, you 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 can assume
that the arrays are parallel i.e., for a fixed subscript N, the elements
Name[N], Gender[N], Month[N],……., AddressArea[N] belong to the same record.
4.7.1 Variable Length Records
Consider an elementary school which wants to keep a record of every student studying in their school.
The record contains the following data:
Name, Telephone Number, Father, Mother, and Siblings.
Here, Father, Mother, and Siblings will contain the names of the student’s father, mother, and brothers
or sisters who attend the same school.
74 LOVELY PROFESSIONAL UNIVERSITY