Binary Search Tree Flashcards
What numbers go on the left and right of the node?
Smaller numbers on the left, bigger numbers on the right.
What is the runtime of binary search?
log(n)
What is the runtime of insert?
log(n)
What is the runtime of delete?
log(n)
What is the runtime of findMin?
log(n)
What is the runtime of findMax?
log(n)
List the traversals and their order.
Pre order: node, left, right
In order: left, node, right
Post order: left, right, node
Breadth: print row by row
How to remove a node with no children?
Just remove the node since there are no kids.
How to remove a node with one child?
Give the child value to the parent.
How to remove a node with two children?
Replace data with the smallest value from the right child. Delete the node on the right.