Deprecated: Implicit conversion from float-string "1537709199.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1537709199.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1537709199.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1537709199.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1537709199.304" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594

Deprecated: Implicit conversion from float-string "1537766104.733" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1537766104.733" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1537766104.733" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1537766104.733" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1537766104.733" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 594
Algorithms: quick sort time complexity
15,785 views

1 Answer

Best answer
4 votes
4 votes
Answer C) O(nlogn),  when median selected as pivot, partition method will divide array into equal halves.. so logn level recursion tree will form with cn work(partition method)  at each level..
The recurence would be..
T(n) = 2T(n/2) + Θ(n)
Therefore total time complexity =Θ(nlogn)  in all cases

Note:O(n) time algo available for median finding
https://en.m.wikipedia.org/wiki/Median_of_medians
edited by

Related questions


Deprecated: Implicit conversion from float-string "1530460981.507" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1530460981.507" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1530460981.507" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1530460981.507" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1542378904.836" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1542378904.836" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1542378904.836" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1542378904.836" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803

Deprecated: Implicit conversion from float-string "1539463626.746" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 796

Deprecated: Implicit conversion from float-string "1539463626.746" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 801

Deprecated: Implicit conversion from float-string "1539463626.746" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 802

Deprecated: Implicit conversion from float-string "1539463626.746" to int loses precision in /var/www/html/qadb/qa-include/app/format.php on line 803
7.6k
views
3 answers
4 votes
Swati verma asked Jun 21, 2017
7,619 views
Time complexity of quick sort when we take pivot from the middle element
3.4k
views
2 answers
3 votes
garvit_vijai asked Jul 1, 2018
3,436 views
Quick sort gives O(nlogn) worst case performance if the pivot is selected as:a) First element of the arrayb) Median of first, last and middle elementsc) Arithmetic mean o...
913
views
1 answers
0 votes
garvit_vijai asked Nov 16, 2018
913 views
Consider the following inputs:1) 2 2 2 2 2 2 22) 1 2 3 4 5 6 73) 7 6 5 4 3 2 1In all three cases, the worst-case time complexity of quicksort is O(n2) My doubt is if I am...
3.8k
views
1 answers
0 votes
Purvi Agrawal asked Oct 13, 2018
3,793 views
In Quicksort let n/7​ th ​ smallest element is chosen using an O(n2​ ) algorithm as thepivot. Calculate the worst case time complexity of the algorithm.