Binary Search Tree 2-3 Trees Flashcards

1
Q

what are the two types of nodes in a 2-3 BST

A
2 nodes (have one key and two children)
3 nodes (have two keys and three children)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

for the three children of a three node, which order are they i

A

the leftmost child is smaller than both the keys
the middle child is in between both the keys
the rightmost child is larger than both of they keys

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

are 2-3 trees always complete

A

yes

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

what does perfect balance mean

A

that every path from root to null link has the same lenght

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

how does search method work in a 2-3 BST

A

compare value being searched for against node
find interval containing search node, follow that link (recursively)
return value if found

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

how does inserting into a 2-3 tree work

A

always add a key into an existing node

insert key into the last node we visited when searching for the key
2 node can become a 3 node

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

how to insert into a 2 node at the bottom of the BST

A

add a new key, making a 3 node from the 2 node

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

how to insert into a 3 node at the bottom of the tree

A

make a temp 4 node
move middle key into parent
repeat up the tree if necessary
if the root is a 4 node, split into 2 nodes (only case where height increases)

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

where is height of tree grown from

A

root only

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

what is the worst case height of a 2-3 bst

A

lgN

all of the nodes are 2 nodes and it acts the same as a normal BST

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

worst case input of keys into a normal bst tree which will result in worst case height

A

insert keys in ascending order

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

best case height of 2-3 bst

A

logbase3N
=lg N

all the nodes are 3 nodes

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

is there a worst case input into a 2-3 bst that will result in wosrt case tree height

A

no

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

guaranteed performance of search and insert in a 2-3 BST

A

logarithmtic

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

why is a 2-3 BST difficult to implement

A

all the different ways of splitting nodes

every time a 2 node is encountered, more comparisons are needed

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