Search Trees_Part_11

Search Trees_Part_11 - Note on Deletion The text (Goodrich,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Note on Deletion The text (Goodrich, p. 445) uses a different convention for BST deletion in their splaying example Instead of deleting the leftmost internal node of the right subtree, they delete the rightmost internal node of the left subtree. We will stick with the convention of deleting the leftmost internal node of the right subtree (the node immediately following the element to be removed in an inorder traversal). CSE 2011 Prof. J. Elder - 51 - Last Updated: 3/3/10 6:14 PM Splay Tree Example CSE 2011 Prof. J. Elder - 52 - Last Updated: 3/3/10 6:14 PM Performance Worst-case is O(n) Example: Find all elements in sorted order This will make the tree a left linear chain of height n, with the smallest element at the bottom Subsequent search for the smallest element will be O(n) CSE 2011 Prof. J. Elder - 53 - Last Updated: 3/3/10 6:14 PM Performance Average-case is O(log n) Proof uses amortized analysis We will not cover this CSE 2011 Prof. J. Elder - 54 - Last Updated: 3/3/10 6:14 PM Other Forms of Search Trees (2, 4) Trees These are multi-way search trees (not binary trees) in which internal nodes have between 2 and 4 children Have the property that all external nodes have exactly the same depth. Worst-case O(log n) operations Somewhat complicated to implement Red-Black Trees Binary search trees Worst-case O(log n) operations Somewhat easier to implement Requires only O(1) structural changes per update CSE 2011 Prof. J. Elder - 55 - Last Updated: 3/3/10 6:14 PM ...
View Full Document

Ask a homework question - tutors are online