BST Deletion Flashcards

1
Q

What is the first step when deleting in a BST?

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

After you have searched for the item to be deleted, what are the 3 possibiities?

A

Once you’ve found the item, there are three possibilities: It’s in:

  • A Leaf
  • A one-child node
  • A two-child node
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you delete a leaf in a BST?

A

To delete a leaf: simply set the parent’s child pointer to null (it’s a linkedlist after all)

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

How do you delete a node with only one child?

What would the attached tree look like if we deleted 19?

A

Simply replace the node with it’s child

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

What is the definition of an inorder successor?

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

In general what do you need to do to delete a node n with two children?

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

What is the code for deletion implementation for easy cases?

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

What do you need to watch out for in implementing code for deletion of easy case?

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

What is code for the helpe-method that deletes a node with two children(not an easy case)?

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

What is the code to implement delete iteratively in a BST (with the two helper cases)?

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