Quicksort, given 3 values, how can I get to 9 operations? -
well, want use quick sort on given 3
values, doesn't matter values, how can worst case 9
operations?
can draw tree , show how show nlogn
, n^2
operations? i've tried find on internet, still didnt manage draw 1 show that.
the worst case complexity of quick sort depends on chosen pivot. if pivot chosen leftmost or rightmost element. worst case complexity occur in following cases:
1) array sorted in same order.
2) array sorted in reverse order.
3) elements same (special case of case 1 , 2).
since these cases occur frequently, pivot chosen randomly. choosing pivot randomly chances of worst case reduced.
the analysis of quicksort algorithm explained in this blogpost khan academy.
Comments
Post a Comment