Data Structure is a means of collecting and organising data so as to perform operations on it efficiently. It is a means to find relationships among data elements for better organization and storage. Let us say that we have the name and age of a number of cricket players and we have to find a way to categorise them. Consider the example of a player with the name “Virat” who is 26 years old. In this example, we’d categorise “Virat” as a string which is a basically a collection of characters and the age as an integer.
We can now get a series of records of players which is stored in the format as mentioned above. Every record has a string and an integer. And thus, this trivial example demonstrates how data structures are useful.
"Dhoni" 30, "Gambhir" 31, "Sehwag" 33
would be how the data would be stored.
In simpler terms, Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily. It should be designed and implemented in such a way that it reduces the complexity and increases the efficiency of access of data elements.
A few examples of standard Data Structures include:
- Linked List
Note: Data Types are not to be confused with Data Structures. Data Types are irreducible as opposed to Data Structures which consist of multiple fields of different data. In the above example, integer is a data type whereas the record(which consists of an integer and a string) is a data structure.