Define Data Structure and differentiate between linear and nonlinear data structures
Data Structure:
- Data Structure is a representation of the logical relationship existing between individual elements of data.
- In other words, a data structure is a way of organizing all data items that considers not only the elements stored but also their relationship to each other
- We can also define data structure as a mathematical or logical model of a particular organization of data items
Linear data structure |
NonLinear data structure |
A data structure is said to be Linear, if its elements are connected in linear fashion by means of logically or in sequence memory locations. |
Nonlinear data structures are those data structure in which data items are not arranged in a sequence. |
Data items can be traversed in a single run. |
Data items cannot be traversed in a single run. |
It is easy to implement. |
It is not easy to implement. |
Examples of Linear Data Structure are Stack and Queue. |
Examples of Non-linear Data Structure are Tree and Graph. |