An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random.

An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random.

Q. An array of 25 distinct elements is to be sorted using quicksort. Assume that the pivot element is chosen uniformly at random. The probability that the pivot element gets placed in the worst possible location in the first round of partitioning (rounded off to 2 decimal places) is  

Solution:

Given an array of 25 distinct elements, and pivot element is chosen uniformly randomly. So, there are only 2 worst case position in the pivot element is either first (or) last.

Therefore, required probability is,

=2/25-

=0.08

So, option (A) is correct.

    

Gkseries: Gkseries.com is a premier website to provide complete solution for online preparation of different competitive exams like UPSC, SBI PO, SBI clerical, PCS, IPS, IAS, IBPS PO, IBPS Clerical exam etc. & other graduate and post-graduate exams. Learn more on about us page