Answer:
A = 42 32 0 0 0 77 23 71 is the list of numbers taken here as the question is incomplete.
L marker moves to the right trying to detect 0s. Each time it detects a 0, the R marker moves to the right, shuffling the data items to the left.
Get the array, A and its size, n
L = 1
R = 2
Repeat the following steps until left > legit
if AL ≠ 0
L ++
R ++
else
legit --
Repeat the following steps until right > n
Copy AR to AR
R ++
R = L + 1
stop
Explanation: The arrangement of data is as follows:
A = 42 32 0 0 0 77 23 71
N = 8; L= 1; R = 2
Iteration 1: 42 ≠ 0 => L = 2; R = 3
A = 42 32 0 0 0 77 23 71
Iteration 2: 32 ≠ 0 => L = 3; R = 4
A = 42 32 0 0 0 77 23 71
Iteration 3: 0 = 0 => N = 7
Copy the remaining elements one position to its left
A = 42 32 0 0 77 23 71
Iteration 4: 0 = 0 => N = 6
Copy the remaining elements one position to its left
A = 42 32 0 77 23 71
Iteration 5: 0 = 0 => N = 5
Copy the remaining elements one position to its left
A = 42 32 77 23 71
Iteration 6: 77 ≠ 0 => L = 4; R = 5
A = 42 32 77 23 71
Iteration 7: 23 ≠ 0 => L= 5; R = 6
A = 42 32 77 23 71
Iteration 8: 71 ≠ 0 => L= 6; R = 7
A = 42 32 77 23 71
L > N ---- stop
final arrangement of the data when the algorithm terminates
42 32 77 23 71