Question 4 The following pseudo code is used to perform quick sort on a given array: Select...
Sigmoid technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Question 4
The following pseudo code is used to perform quick sort on a given array:
public int partition(int[] a, int left, int right) {
int pivot = a[left];
while(left<right) {
while(a[left]< pivot)
left++;
while(a[right] > pivot)
right--;
if(left<right) {
int tmp = a[left];
a[left] = a[right];
a[right] = tmp;
left++;
right--;
}
}
return left;
}
public void recursiveQuickSort(int[] a, int i, int j) {
int idx = partition(a, i, j);
// TODO
}
Select an option:
Show answer & explanation
Answer: A. A) 11 22 33 44 55
Standard computer science and aptitude evaluation.
Step-by-step Derivation:
Step 1: Analyze problem statement.
Step 2: Determine correct option.