Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
makeset
on Jan 16, 2023
|
parent
|
context
|
favorite
| on:
Sorting algorithms that don’t hate you
Because without the insertion cost of fixed locations, insertion sort is also NlogN: just a binary search per element.
bee_rider
on Jan 16, 2023
[–]
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.
adwn
on Jan 16, 2023
|
parent
|
next
[–]
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.
bee_rider
on Jan 16, 2023
|
root
|
parent
|
next
[–]
I guess such a stack would fall over quickly, resulting in a heap. But again not the programming one.
adrianmonk
on Jan 16, 2023
|
parent
|
prev
[–]
Ironically, the answer isn't a stack.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: