Recall & Review
beginner
What is array rotation?
Array rotation means moving the elements of an array to the left or right by a certain number of positions, wrapping around the ends.
Click to reveal answer
beginner
Explain left rotation by 1 on array [1, 2, 3, 4, 5].
Left rotation by 1 moves each element one step to the left. The first element moves to the end. Result: [2, 3, 4, 5, 1]
Click to reveal answer
intermediate
What is the time complexity of rotating an array by d positions using the reversal algorithm?
The reversal algorithm rotates the array in O(n) time, where n is the array length, by reversing parts of the array three times.
Click to reveal answer
intermediate
Describe the reversal algorithm for array rotation.
1. Reverse the first d elements.<br>2. Reverse the remaining elements.<br>3. Reverse the whole array.<br>This rotates the array left by d positions.
Click to reveal answer
beginner
What happens if you rotate an array by its length?
Rotating an array by its length results in the same array because elements wrap around fully and return to original positions.
Click to reveal answer
What is the result of left rotating [10, 20, 30, 40, 50] by 2 positions?
✗ Incorrect
Left rotation by 2 moves first two elements to the end: [30, 40, 50, 10, 20]
Which algorithm rotates an array by reversing parts of it?
✗ Incorrect
The reversal algorithm rotates arrays by reversing segments.
Rotating an array right by 1 is the same as rotating it left by how many positions?
✗ Incorrect
Right rotation by 1 equals left rotation by (array length - 1).
What is the time complexity of rotating an array by copying elements to a new array?
✗ Incorrect
Copying elements to a new array for rotation takes O(n) time.
If you rotate an array by 0 positions, what is the result?
✗ Incorrect
Rotating by 0 means no change to the array.
Explain how the reversal algorithm rotates an array left by d positions.
Think about reversing parts step by step.
You got /4 concepts.
Describe the difference between left rotation and right rotation of an array.
Consider direction and wrapping.
You got /4 concepts.