- If the elements of a data structure result in a sequence or a linear list then it is called a linear data structure. Whereas, traversal of nodes happens in a non-linear fashion in non-linear data structures.
- Lists, stacks, and queues are examples of linear data structures whereas graphs and trees are the examples of non-linear data structures.
You can consider Linear data structures as consecutive blocks . In linear data structures all the elements are in the sequence .for instance element 0 will be before element 1 , and element 2 will be after element 1 . Examples of linear data structures are -
-
array
-
Lists
Non linear data structures on the other hand are simply not linear . Consider tree there is parent node and child node and so . You can also take example of graphs , nodes are connected but not in linear fashion .