NEED OF DS
A data structure helps you to understand the relationships of one data element with the other organize it within the memory. Sometimes the organization might be simple and can be clearly visible, for e.g. list the names of days in a week.
We can visualize that the names of days have a linear relationship between them and thus can be stored in a sequential location or in a type of data structure in which each day points to the next day of the week and it is itself pointed by its preceding day.
Corollary, assume an another set of data that represents location of monuments in a country.
Uttar Pradesh Delhi Maharashtra
Agra Red Fort Qutub Minar Mumbai
Taj Mahal Gateway of India
For each monument the location is given by country name followed by the state name followed by city name, and then finally followed by the monument name.
We can see that such kind of data has a form of hierarchical relationship between them and must be represented in the memory using a hierarchical type of data structure.
The above two example clearly identify the usefulness of a data structure. A data structure helps you to analyze the data, store it and organize it in a logical or mathematical manner.
Selection of particular data structure depends on the following characteristics.
- The data structure must be appropriate enough in structure to reflect the relationship existing between the elements.
- And the structure should be simple so that we can process data efficiency whenever required.
Data structure affects both structural and functional aspects of program.
Algorithm + Data Structure = Program
Classification of Data Structure: It can be classified in two broad categories.
- Primitive Data Structure: These are basic structures and are directly operated upon by the machine instruction. These in general have different representation on different computers. For Example: integer, floating point numbers, characters constant, string constant, pointers etc.
- Non-Primitive Data Structure: These are more sophisticated data structure. These are derived from the primitive data structure. These emphasizes on forming the collection of homogeneous data items. For Example: Lists and Arrays.