Objectives:
A binary search tree (BST) is a binary tree where each node has a Comparable key (and an associated value) and satisfies the restriction that the key in any node is larger than the keys in all nodes in that node's left subtree and smaller than the keys in all nodes in that node's right subtree
A binary search tree (BST) is a binary tree where...
smaller nodes go on the left and larger nodes go on the right.
2
It has at maximum a left and right node NOT an indefinite number of children
Question: How does this compare to binary search in a sorted array?
Question: How does this compare to binary search in a sorted array?
The 2 children case is the complex case
Question: How does this compare to binary search in a sorted array?
function InOrder(BST, visit)
if BST.left
InOrder(BST.left, visit)
visit(BST.value)
if BST.right
InOrder(BST.right, visit)
Can we use a BST to implement a priority Queue? how?
Objectives: