Array Left Shift Algorithm
Consider the following code segment.
int[] values = {10, 20, 30, 40, 50};
int temp = values[0];
for (int i = 0; i < values.length - 1; i++) {
values[i] = values[i + 1];
}
values[values.length - 1] = temp;
for (int i = 0; i < values.length; i++) {
System.out.print(values[i] + " ");
}
What is printed when this code segment is executed?
A
50 10 20 30 40
B
10 20 30 40 50
C
40 50 10 20 30
D
20 30 40 50 10
Question Leaderboard
Not enough data yet to show leaderboard.
