A Linear data structure have data elements arranged in sequential manner and each member element is connected to its previous and next element. This connection helps to traverse a linear data structure in a single level and in single run. Such data structures are easy to implement as computer memory is also sequential. Examples of linear data structures are List, Queue, Stack, Array etc.
A non-linear data structure has no set sequence of connecting all its elements and each element can have multiple paths to connect to other elements. Such data structures supports multi-level storage and often cannot be traversed in single run. Such data structures are not easy to implement but are more efficient in utilizing computer memory. Examples of non-linear data structures are Tree, BST, Graphs etc.
Following are the important differences between Linear Data Structures and Non-linear Data Structures.
|Sr. No.||Key||Linear Data Structures||Non-linear Data Structures|
|1||Data Element Arrangement||In linear data structure, data elements are sequentially connected and each element is traversable through a single run.||In non-linear data structure, data elements are hierarchically connected and are present at various levels.|
|2||Levels||In linear data structure, all data elements are present at a single level.||In non-linear data structure, data elements are present at multiple levels.|
|3||Implementation complexity||Linear data structures are easier to implement.||Non-linear data structures are difficult to understand and implement as compared to linear data structures.|
|4||Traversal||Linear data structures can be traversed completely in a single run.||Non-linear data structures are not easy to traverse and needs multiple runs to be traversed completely.|
|5||Memory utilization||Linear data structures are not very memory friendly and are not utilizing memory efficiently.||Non-linear data structures uses memory very efficiently.|
|6||Time Complexity||Time complexity of linear data structure often increases with increase in size.||Time complexity of non-linear data structure often remain with increase in size.|
|7||Examples||Array, List, Queue, Stack.||Graph, Map, Tree.|