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

No, for 2 reasons,

1. huge data set: heaps requires storing the whole set, but "huge" means "more than you can store"

2. without sorting it: heaps are basically semi-sorted, so you are breaking the rules




You can actually construct the heap from unsorted data in O(n) time, so constructing the heap is definitely not sorting. However, yeah, to actually use the heap to find median in O(n) time, you need to do something similar to magic-five (median of medians) algorithm.


Something like QuickSelect is probably better in practice than median-of-medians.


> but "huge" means "more than you can store"

Really? Where's it coming from?


I think they mean having more than you can store simultaneously on a single device.

With a few exceptions this is pretty common scenario.


More than you can store.

And possibly it's live data.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: