What is the difference between heap and stack in programming(c++) ?
Mar 27, 2025As a C/C++ enthusiast I'm saying it like stack and heap are ways of data structures. They could also be found in other programming languages which in our case we don't care. Stack is like simply a stack for example your cards that you play with your friends you put them as stacks like one on top of each other. Which gives as FILO structure (first in last out) you can only pull a card on the top not from bottom right? And a heap is a binary tree the same as stack in it's purpose to store data but it has it's own properties, like it's have it's own rules for storing data it's not a typical binary tree.
Mar 27, 2025