Open In App

GATE | GATE CS 2019 | Question 31

Improve
Improve
Like Article
Like
Save
Share
Report

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


Answer: (A) 

Explanation: 

Given, 

Total elements =25

The worst-case in quick sort occurs when the pivot element is maximum or minimum. So, only two elements can generate a worst-case scenario. 

Probability of pivot element to be placed at worst location = \\frac {2}{25} = 0.08

Quiz of this Question
Please comment below if you find anything wrong in the above post

 


Last Updated : 10 Jun, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads