Trees Flashcards

1
Q

What is the depth of a node

A

Path from root to node

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

What is the height of a node

A

Longest path from node to any connecting leaf

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

What is the depth of a tree

A

Longest path from root to any leaf

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

What is a full tree

A

Every node has 0 or 2 children

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

What is the average depth of a binary tree

A

sqrt(N)

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

What is the time complexity of insert in BST and why

A

O(n) because it might be unbalanced (lop-sided)

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

What is the rule of an AVL tree

A

Left and right subtrees may only differ in height by 1 max

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

When do you do a single and a double rotation for AVL trees

A

Single when imbalance is on the outside and double when inside

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

What are Splay trees

A

Every node accessed is changed to the root

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

What is complexity of Splay tree operation

A

worst cast o(n), amortized o(logn)

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

which splay operation is the same as which AVL operation

A

zig-zag = double rotation

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