Data Structures19 sections · 729 units
Open in Course

Section Recap

What you learned

Wavelet trees answer range queries on sequences. Structure: Binary tree where each node splits alphabet.

Left child gets smaller half, right gets larger half. Core Operations:

  • Rank: Count occurrences of symbol in prefix
  • Select: Find k-th occurrence of symbol
  • Range quantile: k-th smallest in range

core idea: Recursively halve alphabet, use bitvectors at each level.

Complexity: O(logσ)O(\log \sigma) per query where σ\sigma is alphabet size. Space: O(nlogσ)O(n \log \sigma).