A data structure is a particular way of organizing data in the memory. The main aim of a data structure is to group similar/related items together and bundle them, hence making it easier and efficient to execute the program. Now let us look at the different types of data structures.
A Data Structure is classified into two categories.
Now let us look at the difference between Linear and Non-Linear data structures.
Data is arranged in a linear fashion in which elements are linked one after the other. Data elements in a non-linear data structure are hierarchically related. All the data elements can be traversed in one go, but at a time only one element is directly reachable. All the data elements cannot be traversed in one go as the nodes are not visited sequentially. Linear data structure tends to waste the memory. Efficient utilization of memory. Linear data structures are easy to implement. Implementation of non-linear data structures is complex. Array, Queue, Stack, Linked List are linear data structures. Trees, graphs are non-linear data structures.
Now let us try to get a basic understanding of each of these linear and non-linear data structures.