...
Question 8138 – Data-Structures
April 17, 2024
Computer-Networks
April 17, 2024
Question 8138 – Data-Structures
April 17, 2024
Computer-Networks
April 17, 2024

Question 8518 – Data-Structures

Let P be a quicksort program to sort numbers in ascending order using the first elements as the pivot. Let t1 and t2 be the number of comparisons made by P for the inputs [1 2 3 4 5] and [4 1 5 3 2] respectively. Which one of the following holds?

Correct Answer: C

Question 36 Explanation: 
[1, 2, 3, 4, 5] [4, 1, 5, 3, 2]
Simple one: First element is a pivot element. And if we observe first array pivot is small and requires lot of comparisons and whereas it is not the case with 2nd array through not in sorted manner.
Hence t1> t2.
A
t1=5
B
t1<t2</t
C
t1>t2
D
t1=t2

Leave a Reply

Your email address will not be published. Required fields are marked *