Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ummm.. recursive solution? What will happen if you try to sort a million of items. Don't you run out of stack space at some point.

I know that some compilers are smart, and can inline things, but still method calls are not necessary the most efficient way to go.

Sure, it might look pretty, but it is not efficient.



At 1,000,000 items you have 20 (in the best case, at least) levels of recursion. I can assure you, your stack space is more than sufficient for that.

Also, you only have to push a handful of pointers to the stack, which doesn't seem to be expensive to me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: