Placements roadmap

Trees and heaps

Recursion on trees, ordered data and priority queues. 3 topics, about 15 hours.

  1. Binary trees and BSTs

    About 8 h.

    • Write the four traversals, recursively and with a stack or queue
    • Find height, diameter and lowest common ancestor
    • Insert, delete and validate a BST

    Visualisers: Binary search tree, AVL tree

  2. Heaps and priority queues

    About 4 h.

    • Find the k largest items or merge k sorted lists with a heap
    • Explain why build-heap is O(n)

    Visualisers: Binary heap

  3. Tries and disjoint sets

    About 3 h.

    • Build a trie for prefix search and autocomplete
    • Use union-find to count components and detect cycles

    Visualisers: Trie, Union-find