Lecture 18 - Trees Flashcards
1
Q
When does the worst case happen for trees?
A
When it’s maximally unbalanced
2
Q
When do AVL trees balance themselves?
A
After inserts and deletes
3
Q
What are the properties of Binary Search trees? (3)
A
- The left subtree of a node contains only nodes with keys lesser than the node’s key.
- The right subtree of a node contains only nodes with keys greater than the node’s key.
- The left and right subtree each must also be a binary search tree.
4
Q
What do AVL trees do?
A
Keep the height of the left subtree and the height of the right subtree within a certain threshold (usually 1)