Binary Search Trees - Red Black Trees Flashcards

1
Q

key properties of red black BSTs

A

no node has 2 red links connected to it

every path from root to null link has the same number of black links

red links lean left

root is always black

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

what colour is the root node always

A

black

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

can a red node have a red child

A

no

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

can a red node have a red parent

A

no

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

if a node is red then what colour will both its children be

A

black

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

the red black BST is only balanced when we consider what colour links

A

black

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

guaranteed upper bound for methods in red black bst

A

log n

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

why is log n the guaranteed cost of operations in red black bst

A

making sure we maintain balance means that all the operations will have an upper bound of the height of the tree

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

are leaf nodes counted as red or black nodes

A

black

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

to what direction do red links lean

A

left

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

what are the four members of the node class in a red black tree

A

key
value
noe left and right
boolean colour

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

what does the left rotation method do

A

orient a right leaning red link to the left

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

what does the right rotation method do

A

orient a left leaning link to the right temporarily

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

what does the recolour method do

A

changes colour of node

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

how to insert into a tree with exactly one node (left side)

A

add node with a red link

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

how to insert into a tree with exactly one node (right side)

A

attach with red link

rotate left to make it a legal 3 node

17
Q

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

A

insert with a new red link

if its a right link, rotate left

18
Q

what is the worst case pattern of colour of links in a bst

A

black link red link patter

19
Q

why can hibbard deletion not be performed on red black bst

A

breaks the assumption