Linked lists and trees
Pointer work on linked lists, with reversal, slow and fast pointers and a dummy head, and recursion and level-order search on binary trees.
About 5 hours of study
Learning objectives
- Reverse a list and merge sorted lists with careful pointers
- Find middles and cycles with fast and slow pointers
- Write recursive and queue-based tree functions
Lessons
- 1
Linked list patterns
Reversing a list in place, fast and slow pointers for the middle and for cycles (Floyd's algorithm), merging two sorted lists, and the dummy-head trick.
- 2
Binary trees
Recursion on binary trees: depth, traversals, level-order search with a queue, and checking a binary search tree by passing bounds down.
Module practice
- Middle of a linked listEasy
- Where does the cycle start?Medium
- Reverse in groups of kHard
- Depth of a binary treeEasy
- Level by levelMedium
- Best path in a treeHard
Module quiz
‹ Windows, stacks and binary searchGraphs, heaps and intervals ›