Lecture 18 - Trees Flashcards

1
Q

When does the worst case happen for trees?

A

When it’s maximally unbalanced

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When do AVL trees balance themselves?

A

After inserts and deletes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly