Binary Search Trees Flashcards
1
Q
What do the methods successor and predecessor do?
A
successor(k): brings back an iterator of all of the entries with keys that are greater than k
predecessor(k): with keys less then k
2
Q
state 2 properties of binary search trees
A
- the left child must be smaller than the root, the right child must be larger than the root
- External node do not store anything
3
Q
Provide steps on how the insert method works in this context
A
insert(k,o)
- search k
- assume w is the last node reached by the search
- Insert k at w and expand that into an internal node
4
Q
provide steps to remove a node in a BST
A
5
Q
Height of a BST implemented dictionary?
A
O(n) in worst and O(logn) at best