You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quicksort should first randomly shuffle the container. If it doesn't and the array is already sorted, then it will actually be O(n^2), which is the worst case. By shuffling, it results in a probabilistic guarantee of О(n log n).
Quicksort should first randomly shuffle the container. If it doesn't and the array is already sorted, then it will actually be O(n^2), which is the worst case. By shuffling, it results in a probabilistic guarantee of О(n log n).
https://github.com/kanwei/algorithms/blob/master/lib/algorithms/sort.rb#L180
See: http://stackoverflow.com/questions/27645471/how-does-random-shuffling-in-quick-sort-helps-in-increasing-the-efficiency-of-th
The text was updated successfully, but these errors were encountered: