# BST Insertion Flashcards

What is the first step of a BST insertion?

search for the key you want to insert

What are the two cases for BST insertions

- The tree is empty (the root pointer is null)
- the tree is not empty

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

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

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

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

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?

Draw the following sequencially:

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

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

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

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

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