retagged by
825 views
0 votes
0 votes

retagged by

2 Answers

3 votes
3 votes
Observe that after one pass of quicksort the position of the pivot is same as the position of it in the sorted array.

Sort the array mentally it will be {6,9,11,13,15,17,18,24}

and the given array is {9,6,11,13,18,15,17,24}

So, you will get that that positions of 11,13 and 24 in the given array is same as in the sorted array.

After that check whether all the elements to the left of 11,13 and 24 are less than 11,13 and 24 or not respectively.

Also check whether all the elements to the right of 11,13 and 24 are greater than 11,13 and 24 or not respectively.

You will see that 11,13 and 24 passes this two tests so, 11,13 and 24 can be chosen as pivot.

Hence the answer is 11+13+24 = 48 (Answer)
0 votes
0 votes
After the first pass of the algorithm the pivot element should be in it's correct position i.e the number left to pivot should be smaller and the number right to pivot should be greater.

Hence only numbers 11, 13 and 24 follows above condition.

So sum of all values = 11 + 13 + 24 = 48.

Related questions

0 votes
0 votes
1 answer
2
Gate Fever asked Dec 16, 2018
1,151 views
The median of n elements can be found in O(logn) time.which one of the following is correct about worst case time complexity of quick sort,if always median is selected a...
2 votes
2 votes
5 answers
3
Shubham Sharma 2 asked Feb 7, 2017
2,094 views
Reply with solution @ Habibkhan,@Gabbar,@Arjun Sir
0 votes
0 votes
1 answer
4