โ† Coding Interview Prep (LeetCode) learning path
Coding Interview Prep (LeetCode) ยท Module 7 of 10

Linked lists and trees

Pointer problems and recursive tree traversals.

๐Ÿ“– Key ideas

  1. Reverse a linked list by changing next pointers one by one.
  2. Fast and slow pointers find the middle or detect a cycle.
  3. Tree traversals: preorder, inorder, postorder (DFS) and level order (BFS).
  4. Inorder traversal of a BST gives sorted order.
  5. Many tree problems are short recursive functions on left and right children.
๐Ÿ’ก Real-life example: A linked list is a treasure hunt where each clue points to the next; a tree is a family tree.
Linked listNodes connected by next pointers
Cycle detectionFinding a loop in a list
BSTBinary search tree: left < node < right
Level orderVisit tree level by level