Open In App

GATE | GATE CS 2019 | Question 30

Like Article
Like
Save Article
Save
Share
Report issue
Report

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 _________.

Note: This was Numerical Type question.
(A) 0.08
(B) 0.0016
(C) 0.04
(D) 0.0008


Answer: (A)

Explanation: 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.

Quiz of this Question


Last Updated : 15 Feb, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads