Overview of Linear & Non-Linear Data Structures
Explore the differences between linear and non-linear data structures including lists, trees, and graphs. Understand their traversal methods and time-space complexities to help you decide the best data structure for your coding tasks.
We'll cover the following...
Now that we have covered all the popular data structures, let’s see which of them are linear and which are non-linear. This information is useful when deciding the appropriate data structure for our algorithm.
Linear Data Structures
In linear data structures, each element is connected to either one (the next element) or two (the next and previous) more elements. Traversal in these structures is linear, meaning that insertion, deletion, and search work in O(n).
Lists, linked lists, stacks, and queues are all example of linear data structures.
Non-Linear Data Structures
The exact opposite of linear data structures is non-linear data structures. In a non-linear data structure, each element can be connected to several other data elements. Traversal is not linear and, hence, search, ...