Consider the following set of integers. {20,25,57,48,37,12,92,86,33} If one uses the quick sort algorithm to sort the above set of integers, how many p to completely sort the file? Note: you may choose middle element as a pivot
Answers
Answer:
37
Explanation:
12 20 25 33 37 48 57 86 92
ie: 37 is the middle element as a pivot
Answer:
The number of p's that are required to completely sort the given array by the method of the Quick Sort Algorithm is found to be: 5
Explanation:
The Quick sort is based on the concept of a divide-and-conquer algorithm that is also used in merge sort. The difference is that in fast sort, the most important or required work is done when splitting (or dividing) an array into sub-arrays, whereas in merge sort, all the main work is done by merging sub-arrays. That is for quicksort, the join step is irrelevant.
Quick sort is also known as partition exchange sort. This algorithm divides an array of specified numbers into three main parts.
- Elements less than pivot elements
- Pivot element
- Elements larger than the pivot element
Pivot elements can be selected in various ways from the specified numbers.
- Selection of the first element
- Last item selection (example shown)
- Select a random item
- Median selection
#SPJ3