Hacker News new | past | comments | ask | show | jobs | submit login

Heap sounds like overkill to find the middle value in a running list. What's wrong with simple stack and keeping track of how many integers you've received?



What's wrong with simple stack and keeping track of how many integers you've received?

I'm sorry, but I have absolutely no idea what you are talking about. Perhaps you could describe your solution a bit more.


I'm not sure what you have in mind (perhaps finding the mean? but why the stack?) but that would not work for median.


Your solution is for median position, not median value, and it would require a queue, not a stack, so unneeded old values could be dropped.


Of course, a queue is correct.




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

Search: