575 views

1 Answer

Best answer
4 votes
4 votes

Basically what we need to know here is the position of pivot which is 60 in this case after applying the first pass of partition algorithm.A pass of partition algorithm is completed when the pivot chosen gets its proper place.Using iterative quicksort method (see the partition of algo of this : http://www.geeksforgeeks.org/iterative-quick-sort/) , we find after 1st pass , the array looks like :

55  15  7  12  35  60  80  90  95

So we can see all elements less than 60 are at its left side and all elements right to 60 are greater than it.In other words , 60 which is the pivot has got its correct place.This is the required effect of partition algo.

Now , according to the question , we need to find arrangements preserving this effect.So all elements left to 60 can be permuted and all right elements to 60 can be permuted but separately so that the position of 60 is not disturbed.

Hence , no of arrangements in left part = 5!= 120(since no of elements left of 60 = 5]

and no of arrangements in right part = 3!= 6

So total no of required no of ways by multiplication principle = 120 * 6 = 720

Hence , 720 should be the required no of ways

selected by

Related questions

0 votes
0 votes
1 answer
3
iarnav asked Jan 11, 2018
550 views
How to find log of the first n natural numbers?$T(n)= \log 1+ \log 2+ \log 3+\ldots + \log n$ // How to proceed from here?
1 votes
1 votes
1 answer
4
richa07 asked Oct 11, 2016
198 views
According to me answer should be 0(n).