Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quicksort's space complexity #59

Merged
merged 1 commit into from Mar 16, 2015
Merged

Conversation

mamigot
Copy link
Contributor

@mamigot mamigot commented Dec 19, 2013

@mxj4
Copy link

mxj4 commented Jan 8, 2014

Yes it should be O(log(n)), please fix.

@bbodenmiller
Copy link

@ericdrowell I think this should be merged before the others.

@BartMassey
Copy link
Contributor

Quicksort is O(n) worst case space complexity unless you are clever about it. The worst case is the case in which the time complexity is n^2 because pivots have been chosen poorly: there will be n levels of recursion, each with its own pivot point stored, so n auxiliary storage. Sedgewick discusses the use of tail-call on the larger partition to eliminate these stack frames, making the worst-case storage O(log n), but I've never seen anybody implement it like that in practice: if you aren't getting the average case O(log n) time complexity out of Quicksort, the extra storage is the least of your worries.

ericdrowell added a commit that referenced this pull request Mar 16, 2015
Quicksort's space complexity
@ericdrowell ericdrowell merged commit 3ea60f8 into ericdrowell:master Mar 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants