โ Coding Interview Prep (LeetCode) learning pathCoding Interview Prep (LeetCode) ยท Module 7 of 10
Linked lists and trees
Pointer problems and recursive tree traversals.
๐ Key ideas
- Reverse a linked list by changing next pointers one by one.
- Fast and slow pointers find the middle or detect a cycle.
- Tree traversals: preorder, inorder, postorder (DFS) and level order (BFS).
- Inorder traversal of a BST gives sorted order.
- 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