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

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

state 2 properties of binary search trees

A
  1. the left child must be smaller than the root, the right child must be larger than the root
  2. External node do not store anything
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Provide steps on how the insert method works in this context

A

insert(k,o)

  1. search k
  2. assume w is the last node reached by the search
  3. Insert k at w and expand that into an internal node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

provide steps to remove a node in a BST

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

Height of a BST implemented dictionary?

A

O(n) in worst and O(logn) at best

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