Browse curriculum

Advanced Topics

Advanced Data Structures and Techniques

These are the structures that appear when a problem needs repeated range queries, repeated prefix lookups, or repeated connectivity checks, and a linear scan per query is too slow. They come up in the harder end of interviews and constantly in competitive programming.

The material assumes the earlier topics are solid — segment trees make sense once binary trees do, and disjoint sets are much clearer after graph connectivity. Each lesson visualises the operation that gives the structure its advantage: the range decomposition in a segment tree, the path compression in a disjoint set, the shared prefixes in a trie.

17

Interactive lessons

6

Languages (JS, TS, Python, Java, C, C++)

Lessons

Advanced Topics lessons

Complexity

Advanced Topics time and space complexity compared

Best, average and worst-case running time and extra space for every advanced topics lesson, as each lesson derives them.

LessonBestAverageWorstSpace
IntroductionVariesVariesVariesVaries
IntroductionO(1) (Peek)O(log N) (Insert/Delete)O(log N) (Insert/Delete)O(N)
Heap OperationsO(1) (Insert if no swim needed)O(log N)O(log N)O(N)
Heap SortO(N log N)O(N log N)O(N log N)O(1)
IntroductionO(1)O(N) (Naive)O(N) (Naive)O(N)
Optimized Union-FindO(α(N))O(α(N))O(α(N))O(N)
IntroductionO(N)O(N log K)O(N log K)O(K)
Kth Largest ElementO(N)O(N log K)O(N log K)O(K)
IntroductionO(N log N)O(N log N)O(N log N)O(N)
Meeting Rooms IIO(N log N)O(N log N)O(N log N)O(N)
IntroductionO((N+Q)*sqrt(N))O((N+Q)*sqrt(N))O((N+Q)*sqrt(N))O(N)
Mo's AlgorithmO((N+Q) * sqrt(N))O((N+Q) * sqrt(N))O((N+Q) * sqrt(N))O(N + Q)
TriesO(1)O(L)O(L)O(N*L)
Z-AlgorithmO(N)O(N)O(N)O(N)
Suffix ArrayΩ(N² log N)Θ(N² log N)O(N² log N)O(N) to O(N²)
Bitmask DPO(N * 2^N)O(N^2 * 2^N)O(N^2 * 2^N)O(N * 2^N)
Matrix ExponentiationO(k^3 log N)O(k^3 log N)O(k^3 log N)O(k^2)
Curriculum

Continue the DSA curriculum

Advanced Topics is one of 12 topics in the interactive DSA visualizer curriculum. Once this topic is comfortable, the coding interview pattern library reorganises the same material around the patterns interview questions are built on.

Directory

Every other DSA visualizer