BST Insertion Flashcards

1
Q

What is the first step of a BST insertion?

A

search for the key you want to insert

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

What are the two cases for BST insertions

A
  1. The tree is empty (the root pointer is null)
  2. the tree is not empty
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does root look like before and after adding an item to an empty tree?

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

What is the specific code to insert into an empty BST?

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

In general, what do we need to do to insert into a BST that is not empty?

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

In the attached example, where would prev and curr be when inserting 19 into the BST

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

In a BST insertion, after we have determined the correct spot using prev and curr, what is the next step?

How do you determine the appropriate child of prev?

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

Draw the following sequencially:

Insert 15, 8, 12, 19, 5 and 23 into an initially empty BST

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

What is the iterative insert code if the BST is NOT empty(after the initial else condition)

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

In the BST class, what is the code for the recursive public driver method for insert?

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

In the Node class, what is the code for the recursive helper method?

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

Draw the table diagram of adding 20 into the following recursive insertion method for a BST

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