Trees general Flashcards

1
Q

Binary tree

A

A tree where each node has at most two children

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

pre-order traversal

A

Process the root, followed by the left subtree, then the right subtree

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

In-order traversal

A

Process the left subtree, followed by the root, then the right subtree

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

Post-order traversal

A

Process the left subtree, followed by the right subtree, then the root

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

Complexity of most simple operations on a binary tree - best case

A

O(log(N)) - Tree is even/balanced

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

Complexity of most simple operations on a binary tree - worst case

A

O(N) - Tree devolves into a list

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

Binary search tree (BST)

A

Binary tree where for each element, elements less than it are in its left subtree, and elements greater than it are on its right subtree

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

AVL tree

A

A BST where the balance factor is between -1 and 1

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

Demonstrate a left rotation on a tree

A

Answer text intentionally blank

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

Demonstrate a right rotation on a tree

A

Answer text intentionally blank

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

How would an AVL be rebalanced if an outer subtree is larger?

A

Preform a rotation towards the center

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

How would an AVL be rebalanced if an inner subtree was larger?

A

Rotate away from center on that side’s child, then towards center on itself.

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