edited by
849 views
0 votes
0 votes

The worst-case running times of Insertion sort, Merge sort and Quick sort respectively are

  1. $\Theta(n\operatorname{logn}), \Theta\left(n^{\wedge} 2\right), \Theta\left(n^{\wedge} 2\right)$
  2. $\Theta\left(n^{\wedge} 2\right), \Theta(n \log n ), \Theta(n \log n)$
  3. $\Theta\left(n^{\wedge} 2\right), \Theta(n\operatorname{logn}), \Theta\left(n^{\wedge} 2\right)$
  4. $\Theta\left(n^{\wedge} 2\right), \Theta\left(n^{\wedge} 2\right), \Theta(n\operatorname{logn})$

     

edited by

2 Answers

1 votes
1 votes

1. Insertion Sort:

  • Worst-case occurs when the array is in reverse order.
  • Requires comparing and potentially shifting elements for each insertion.
  • Leads to a quadratic time complexity of O(n^2).

2. Merge Sort:

  • Consistently divides the array into halves and merges sorted subarrays.
  • Worst-case and average-case time complexities are both O(n log n).
  • The log n factor comes from the repeated halving of the problem size.

3. Quick Sort:

  • Worst-case occurs when the pivot consistently divides the array unevenly.
  • Leads to a quadratic time complexity of O(n^2) in this scenario.
  • However, the average-case time complexity is O(n log n).

The answer is (C) O(n^2), O(n log n), O(n^2).

Related questions

0 votes
0 votes
2 answers
1
admin asked Oct 21, 2023
3,944 views
Given $3$ literals $\text{A, B}$, and $\text{C}$, how many models are there for the sentence $\text{A $\vee$ $\neg$ B $\vee$ C}$ ?
1 votes
1 votes
2 answers
2
admin asked Oct 21, 2023
3,501 views
Which of the following first-order logic sentence matches closest with the sentence "All students are not equal"?$\forall x \exists y[\operatorname{student}(x) \wedge \op...
0 votes
0 votes
1 answer
3
admin asked Oct 21, 2023
1,657 views
The mean of the observations of the first $50$ observations of a process is $12$. If the $51$ $\text{st}$ observation is $18$, then, the mean of the first $51$ observatio...