Linear vs non-linear

The notes

Linear data structures

Data elements are arranged in a sequential or consecutive manner.

Characteristics

  • Single-level structure
  • Sequential traversal (one path)
  • Previous and next element connected

Examples

  • Array
  • Linked list
  • Stack (LIFO: push and pop at the same end)
  • Queue (FIFO: enqueue at the back, dequeue at the front)

Non-linear data structures

Data elements are not arranged in any sequence; they form hierarchical or complex connections.

Characteristics

  • Multi-level structure
  • Multiple paths for traversal
  • Each element can connect to several other elements

Examples

  • Tree (root, parent and child nodes)
  • Graph (nodes connected by edges)

Data structures deck

  1. 1. Linear vs non-linear
  2. 2. Arrays
  3. 3. Hashmaps
  4. 4. Stacks
  5. 5. Queue
  6. 6. Linked list
  7. 7. Binary tree
  8. 8. BST
  9. 9. Graphs
  10. 10. Heaps