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

Because without the insertion cost of fixed locations, insertion sort is also NlogN: just a binary search per element.


Hey wait, good point, what the heck kind of data structure even is a stack of papers? You can insert like a linked list but hop around like an array.


Only for reasonably small stacks. Insertions at random indices won't stay O(1) when you're dealing with 100k pages and more – i.e., when you can't pick them up in one movement.


I guess such a stack would fall over quickly, resulting in a heap. But again not the programming one.


Ironically, the answer isn't a stack.




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

Search: