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

Lessons

  1. 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. 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

Module quiz

1. Why use a dummy head node?
2. When fast reaches the end of the list, where is slow?
3. What happens if you set head.next = prev before saving head.next while reversing?
4. What is the base case of recursive tree depth?
5. To check a binary search tree, what do you pass down the recursion?
6. A path in a tree may skip the root. In a max-path-sum solution, a child with a negative best downward path contributes...

‹ Windows, stacks and binary searchGraphs, heaps and intervals ›