Question: Write the following pseudo code as Java code: Algorithm foo (int[] A : an array of N integers) int x = A [0] int p
Write the following pseudo code as Java code:
Algorithm foo (int[] A : an array of N integers)
int x = A [0]
int p = 0
int f = 1
for(int i = 1; i < N ; i ++)
if(A [i ] < x )
swap A [i ] and A [f ]
swap A [p ] and A [f ]
p ++
f ++
else if (A [i ] == x )
swap A [f ] and A [i ]
f ++
end for
end foo
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
