Algorithms and Data Structures · Senior · Question 38 of 75

What does structural sharing in persistent data structures give you?

Explanation

Updating one leaf of a tree copies only the path to the root, O(log n), and old versions stay valid. Immutable updates in Redux, Immer and Clojure collections rely on this; it also makes === change checks cheap.

Further reading

Problem with a question

Algorithms and Data Structures · Senior · question 38

Test yourself

Take the Algorithms and Data Structures · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz