AVL Flashcards

1
Q

What is the balance factor of a node?

A

The balance factor of a node describes how balanced the
subtree of that node is and, if it is not perfectly balanced,
which side of the subtree (left side or right side) is “heavier”.

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

How is balance factor calculated?

A

The balance factor of a node is calculated by subtracting the height of the left subtree by the height of the right subtree.

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

When is an AVL tree considered balanced?

A

A balance factor between -1 and 1 (inclusive) means that the subtree is considered balanced.

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

When does a Left Rotation happen?

A

A left rotation happens when you have a node whose balance factor is -2, and its right child has a balance factor of 0 or -1.

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

What happens in a left rotation?

A

The top node becomes the left

child of the middle node.

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

When does a Right Rotation happen?

A

A right rotation happens when you have a node whose balance factor is 2, and its left child has a balance factor of 0 or 1.

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

What happens in a right rotation?

A

When a right rotation happens, the top node becomes the right child of the middle node.

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

When does a Left - Right rotation happen?

A

It happens when you have a node whose balance factor is 2, and its left child has a balance factor of -1.

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

What happens in a Left - Right rotation?

A

When a left-right rotation happens, the top node becomes the right child of the bottom node, and the middle node becomes the left child of the bottom node.

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

When does a Right - Left rotation happen?

A

It happens when you have a node whose balance factor is -2, and its right child has a balance factor of 1.

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

What happens in a Right - Left rotation?

A

The top node becomes the

left child of the bottom node, and the middle node becomes the right child of the bottom node.

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

What is the average case Big O for inserting in an AVL?

A

O ( log n )

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

What is the average case Big O for searching in an AVL?

A

O ( log n )

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

What is the average case Big O for deleting in an AVL?

A

O ( log n )

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

What is the worst case Big O for inserting in an AVL?

A

O ( log n )

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

What is the worst case Big O for searching in an AVL?

A

O ( log n )

17
Q

What is the worst case Big O for deleting in an AVL?

A

O ( log n )