Professional Documents
Culture Documents
Practise Test-1
Practise Test-1
Since A[i] <= A[k] and A[k] <= A[j] => I = k; Then exchange A[I] <=> A[r]
12 13 5 6 67 34 23 78 => 12 13 5 6 67 78 23 34
x = A[r] = 34; j = 4 (A[j] = 67); j = 4 (A[j] = 67);
QUICKSORT(A, 1, 4)
12 13 5 6 23 => i = 0 (A[i] = 12); j = 1 (A[j] = 13); k = 2 (A[k] = 5)
Since A[i] <= A[j] and A[k] <= A[i] => I = i; Then exchange A[I] <=> A[r]
23 13 5 6 12 (12 <=> 23);
5 13 23 6 12 (23 <=> 5);
5 6 23 13 12 (13 <=> 6);
5 6 12 13 23 (23 <=> 12);
Sorted array: 5 6 12 13 23 34 67 78
Q2 For the same above sequence, apply INSERTION sort to arrange the sequence . Show all
the steps clearly
12 13 5 6 67 34 23 78
Sorted array: 5 6 12 13 23 34 67 78