Data Structures19 sections · 729 units
Open in Course

Intro

Why persistence matters

You update a data structure. Later, you need to query its state before that update. What do you do? Naive approach: Copy the entire structure before each update.

Space: O(n)O(n) per operation. Persistent approach: Create new nodes only for the changed parts. Share unchanged parts with previous versions.

Space: O(logn)O(\log n) per operation for tree structures. Persistent data structures keep all historical versions accessible.

After version kk operations, you can query any version 00 to kk. In this section, I'll teach you persistence for arrays, segment trees, and other structures. You'll learn path copying, the fat node method, and applications to problems requiring version history.