Skip to content
Snippets Groups Projects
Commit ec003e03 authored by Jiří Škrobánek's avatar Jiří Škrobánek
Browse files

Annotate path-copying

parent 04384930
No related branches found
No related tags found
No related merge requests found
...@@ -59,6 +59,10 @@ Pointers in new vertices are updated to point to new copies of corresponding ver ...@@ -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. 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. 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. 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. 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. ...@@ -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. There is no apparent construction that would not increase memory complexity by copying the paths.
\figure[path-copying]{path-copying.pdf}{}{Path copying} \figure[path-copying]{path-copying.pdf}{}{Path copying}
% TODO: Annotate
This outlined method is not exclusive to binary search trees. 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. It may be used to obtain functional variants of more variants of pointer data structures, of which binary search trees are a prime example.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment