edited by
1,002 views
1 votes
1 votes
Which of the following statement(s) is/are true?

(a) Quicksort and merge sort are both examples of divide and conquer algorithms.

(b) If we randomly choose a pivot element each time, quicksort will always terminate in time $O(n log n).$

(c) For every fixed strategy to choose a pivot for quicksort, we can construct a worst case input that requires time $O(n)$.

(d) If we could find the median in time $O(1)$, quicksort would have worst case complexity $O(n log n)$.

plese give answer and explain it why ?
edited by

1 Answer

5 votes
5 votes

Option A) Both $Quick Sort $ and $MergeSort$  are both examples of divide and conquer.In $MergeSort$ we do blind division and try to conquer on the small sub problems while in $QuickSort$ we perform meaning division so we don’t bear the conquer cost.

Option B)If we randomly choose a pivot the quick sort will not end up giving $\Theta$(nlogn) Time complexity in every case but less no of groups will the worst case of $\Theta$(n$^{2}$). for sure.

Option C)Every partition technique takes $O(n)$ to choose the pivot whether its Hoare or Lomuto
Analysis of Hoare vs Lomuto:https://en.wikipedia.org/wiki/Quicksort 

Option D)Given that we can find the median in 0(1) we can always simulate $QuickSort$ to perform in $\Theta$(nlogn) but generally the median finding takes more time and $Merge Sort$ out performs the constant factor that gets added for $median$ using the median of medians finding and then applying the $QuickSort$.

Correct answers will be option $A)$,$C)$and $D)$

edited by

Related questions

1.2k
views
3 answers
0 votes
aditi19 asked Oct 6, 2018
1,184 views
what is the recurrence relation for merge sort?
648
views
1 answers
0 votes
Shankar Jha asked Jun 15, 2018
648 views
Assume that merge sort algorithm in the worst case takes 30 seconds for an input of size 64 which of The following most closely approximates the maximum input size of a problem that can be solved in 6 minutes
191
views
0 answers
0 votes
Huzaifa0111 asked Aug 27, 2023
191 views
479
views
1 answers
1 votes
meethunjadhav asked Jul 30, 2018
479 views
suppose merge sort takes 2 sec to sort a set of 64 keys then how much time will take to sort a set of 512 keys?here, ans is 24 sec how it is plz explain me.