diff --git a/201-persist/persist.tex b/201-persist/persist.tex index 96ebc641fba104fcac00a235d43350718b845682..83d2d65344ebf56c57f40a44dc664e49c12a717c 100644 --- a/201-persist/persist.tex +++ b/201-persist/persist.tex @@ -59,6 +59,10 @@ Pointers in new vertices are updated to point to new copies of corresponding ver The root of the newly created version is the copy of the original root. Thus the new version now shares some vertices with the old version. Here we tacitly assume that only pointers to children are stored. Updating the root in a tree with pointers to parents would involve creating copies for all nodes in the tree. +Insertion of a vertex G is depicted in figure \figref{path-copying}. +We can see an original tree with vertices A, B, C, D, E, F. +The thick vertices are created by the insert operation. + This method yields a functional data structure since the old version of the tree was technically not modified and can still be used. With reasonable variants of binary search trees, achieved time complexity in a tree with $n$ vertices is $\Theta(\log n)$ per operation and $\Theta(\log n)$ memory for insert/delete. @@ -66,7 +70,6 @@ The downside of this method is the increased space complexity. There is no apparent construction that would not increase memory complexity by copying the paths. \figure[path-copying]{path-copying.pdf}{}{Path copying} -% TODO: Annotate This outlined method is not exclusive to binary search trees. It may be used to obtain functional variants of more variants of pointer data structures, of which binary search trees are a prime example.