Answer:
and
Explanation:
GIVEN: an array of ten integers
.
TO FIND: If we partition this array using Quick sort's partition function and using
for the pivot. List the elements of the resulting array after the partition finishes.
SOLUTION:
quick sort is a divide and conquer algorithm in which an array is partitioned into sub-arrays about an pivot element by checking whether elements are greater than pivot or and then sub arrays are sorted recursively.
Here
is the pivot element.
two arrays will be created, in first array element less than or equal to pivot element are stored in other elements greater than pivot element are stored.
Starting from first element of array
elements in first array will be
elements in second array will be
Hence the resulting array after the partition finishes are
and