Tech IndustryAug 12, 2022
Aurorasethm

Stack vs heap

Interviewing for a staff swe position and the recruiter asked me what's the difference between a stack and a heap. I said a heap is like a laundry bag and a stack is what your dirty dishes look like. I got an email reject after this phone screen. F.

Tesco NadurMonje Aug 12, 2022

Not everyone realises heap (as in memory heap) is not the same as a min/max heap. They were, perhaps, thinking of min/max heap, not the other heap

Northrop Grumman minTC Aug 13, 2022

I always ask if they mean the abstract data types or memory

LinkedIn not[in] Aug 12, 2022

If you're wondering why, a heap is a tree structure. Can't imagine how it's like a laundry bag

New
matchgreen Aug 12, 2022

OP tried to oversimplified it. It's not wrong but recruiter was looking for textbook definition

New
wVEw75 Aug 12, 2022

“A” stack and “a” heap, or “the stack” and “the heap”. The former refers to the data structures and the latter to the memory segments.

LinkedIn SLBA62 Aug 12, 2022

Play stupid games win stupid prizes

Microsoft cjLG02 Aug 12, 2022

Nice answer

Google ABC-CEO Aug 12, 2022

How would you answer lock vs semaphore?

New
matchgreen Aug 12, 2022

Noice!

Snap kuiio Aug 12, 2022

Why here? Stackoverflow

Roblox Broblox Aug 13, 2022

If someone didn't know the difference in an interview, they'd be in stack of trouble.

Western Digital Phan Tom Aug 13, 2022

You malloc from the heap and you push and pop from the stack. Heap can get fragmented but can malloc and free out of order but you cannot push and pop stack out of order. What major?