Ruby quick sort, not so quick, (ruby)

Status
You're currently viewing only andrewme's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

andrewme

Senator
7,120
Subscriptor
Orionpaul":qdbertj3 said:
I suppose looking at my code, I could reduce the function calls (and thus the stack) by making the pivot function simply a part of the quicksort function itself, and see if I get any improvement that way.

No, that shouldn't help. The "partition" call isn't part of the recursive path, so eliminating it wouldn't make the call stack any shallower.

quicksort on 80,000 items should require a stack depth of only ~17. What depth is it failing at? Does ruby have a debugger you can use to see a stack trace when the failure occurs? Does ruby have a hard-coded or configurable maximum stack depth?
 
Status
You're currently viewing only andrewme's posts. Click here to go back to viewing the entire thread.
Not open for further replies.