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

I remember being asked once in a job interview what I thought about heaps. I confessed that I didn't recall the specifics of all the different variants of that data structure as I hadn't had the occasion to use one before. https://en.wikipedia.org/wiki/Heap_(data_structure)#Variants

It turned out he was asking about dynamic memory allocation, i.e., malloc/free and new/delete.

(I didn't get the job)




Hehe, it happens.

Speaking of memory allocation, the stack is named that way because it's an actual stack and most function calls receive parameters through it and return their results through it. This is why it's cheaper to store things on the stack, because if you want to use a value from memory, it's going to end up on that stack anyway (e.g. boxing / unboxing), not to mention that items get allocated and deallocated in LIFO order, so you've got no issues with searching for available space or fragmentation.




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

Search: