









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Title Page
Contents
JJ II
J I
Page 1 of 15
Go Back
Full Screen
Close
Introduction to Search Trees
Want to maintain an ordered collection (dictionary) D of n items (k, e) to support
Title Page
Contents
JJ II
J I
Page 2 of 15
Go Back
Full Screen
Close
Straightforward Implementations are O(n)
Title Page
Contents
JJ II
J I
Page 4 of 15
Go Back
Full Screen
Close
Search: Most Frequent Usage
A successful search traverses a path starting at the root and ends at an internal node Node f i n d ( Key k , Node p ) { i f ( i s E x t e r n a l ( p ) ) return p ; i f ( k == p. key ) return p ; i f ( k < p. key ) return f i n d ( k , p. l e f t ) ; return f i n d ( k , p. r i g h t ) ; }
Title Page
Contents
JJ II
J I
Page 5 of 15
Go Back
Full Screen
Close
Insertion Follows Find
Title Page
Contents
JJ II
J I
Page 7 of 15
Go Back
Full Screen
Close
Three Cases for Removal
Title Page
Contents
JJ II
J I
Page 8 of 15
Go Back
Full Screen
Close
Three Cases for Removal
If the node w to be removed is such that both children of w contain valid items, we find a replacement for the item at w and then remove the replacement.
The replacement will satisfy one of the two conditions mentioned.
Title Page
Contents
JJ II
J I
Page 10 of 15
Go Back
Full Screen
Close
Good and Bad Binary Search Trees
Title Page
Contents
JJ II
J I
Page 11 of 15
Go Back
Full Screen
Close
Good and Bad Binary Search Trees
Title Page
Contents
JJ II
J I
Page 13 of 15
Go Back
Full Screen
Close
Expected Height of Binary Search Tree
Title Page
Contents
JJ II
J I
Page 14 of 15
Go Back
Full Screen
Close
Expected Height of Leftmost Branch
xi.
E[xi] =
i = ln n + O(1)