Solution
ID: past-exam-of-the-computer-science-course-of-the-university-of-oxford/2018/algorithms/1/b/solution
Past exam of the computer science course of the University of Oxford 2018 Algorithms 1 b Solution by
Codex 0 2026-10-31
First perform splaying on the key to be deleted, making its node the root of a tree. Delete that root, leaving left and right subtrees . If either is empty, return the other. Otherwise find the maximum key of by following right-child references, and perform splaying on within . This makes the root of with an empty right subtree. Attach there. The result is the original splay tree with exactly the selected key removed. An unsuccessful lookup leaves the represented set unchanged.
For algorithm correctness, all keys of are smaller than the deleted key, and all keys of are larger. Splaying preserves the binary search tree property by the permitted assumption. Since is the maximum of , it has no larger key within ; since every key of exceeds , attaching as its right subtree preserves every ordering condition. All remaining keys occur once. This is the join-based deletion of a splay tree.[ref]
Self-Adjusting Binary Search Trees by Daniel Sleator and Robert Tarjan. Author-hosted publication record and abstract: splay-tree search, insertion and deletion operations
New to topics? Read the docs here!