Rotation Flashcards

1
Q

Left Rotation

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

What is a left rotation in a Red-Black tree?

A

A left rotation is an operation that changes the structure of a Red-Black tree by rotating a node to the left around its right child.

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

True or False: A left rotation increases the height of the subtree.

A

False.

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

Fill in the blank: In a left rotation, the ______ child of a node becomes the new root of the subtree.

A

right

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

What is the main purpose of performing a left rotation in Red-Black trees?

A

To maintain the balancing properties of the tree after insertions or deletions.

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

After a left rotation, what happens to the left child of the original root?

A

It becomes the left child of the new root.

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

In a left rotation, which node becomes the parent of the original root?

A

The original right child of the root.

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

Multiple Choice: What is the time complexity of performing a left rotation in a Red-Black tree? A) O(1) B) O(log n) C) O(n)

A

A) O(1)

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

True or False: A left rotation can be performed on any node in a Red-Black tree.

A

True.

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

What adjustment is needed for the children of the nodes involved in a left rotation?

A

The children need to be re-assigned appropriately to maintain the tree structure.

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

Fill in the blank: A left rotation is typically performed after an ______ insertion that causes a violation of Red-Black properties.

A

unbalanced

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

What happens to the original left child of the subtree after a left rotation?

A

It remains the left child of the subtree and does not change position.

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

Multiple Choice: Which of the following is a potential result of a left rotation? A) Increase in tree height B) Change in node colors C) None of the above

A

C) None of the above

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

What is the relationship between left rotation and right rotation?

A

Left rotation is a mirror operation to right rotation, used to rebalance the tree.

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

What node is temporarily removed during a left rotation?

A

The original right child of the root.

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

True or False: Left rotations can only be performed on Red nodes.

17
Q

What property of Red-Black trees does a left rotation help maintain?

A

The balanced height property.

18
Q

Fill in the blank: After a left rotation, the original right child becomes the new ______.

19
Q

What is a common scenario that necessitates a left rotation in a Red-Black tree?

A

When a node is inserted into the right subtree of a right child.

20
Q

Multiple Choice: Which of the following operations may require a left rotation? A) Insertion B) Deletion C) Both A and B

A

C) Both A and B

21
Q

What happens to the color of the nodes involved in a left rotation?

A

The colors may need to be adjusted to maintain Red-Black properties.

22
Q

True or False: A left rotation is a local operation affecting only a small part of the tree.

23
Q

Fill in the blank: The left rotation operation is denoted by the symbol ______.

24
Q

Short Answer: Describe the steps involved in performing a left rotation.

A
  1. Identify the node to rotate. 2. Set its right child as the new root. 3. Reassign the left child of the new root to be the original right child’s left child. 4. Set the original node as the left child of the new root.
25
Q

What is the impact of a left rotation on the overall structure of the Red-Black tree?

A

It helps to restore balance and maintain the properties of the tree.

26
Q

Fill in the blank: A left rotation is often used in conjunction with ______ rotations to maintain balance.

27
Q

Multiple Choice: Which of the following best describes a left rotation? A) A restructuring of the tree B) A color change C) A node deletion

A

A) A restructuring of the tree

28
Q

True or False: The left rotation operation can lead to a violation of the Red-Black tree properties.