4 ms·
Your first sentence was enough for me to up-vote you, without reading the rest of the comment. Also, your whole explanation is unnecessary, when this advice is
by bad_user 13y ago
Your first sentence was enough for me to up-vote you, without reading the rest of the comment.
Also, your whole explanation is unnecessary, when this advice is analogous to ... stop using stacks!
I would add queues here too, though people might mistake that for priority queues, which can be modelled as trees.
- marshray 13y agoI 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 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)
- bad_user 13y agoHehe, 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.