Rather depends on where and how they are implemented.
Anyway which is faster for what?
Actually, I don't know! I am a computer engineer (fresher) , looking for job. They had this question in the test paper for a job. It was exactly " Which is faster - heap or stack? Explain with example" . And I didn't know what was it about!
Could u tell something?
I'll b really grateful !
Thanks
I wouldn't really expect 1 to be faster than the other they should both be in RAM for the current platform so they should both go about the same speed.
Generally you only use the stack for auto variables and these are allocated for you where as you use the heap when you malloc or new variables so allocating memory on the stack is marginally faster as it is done as part of the function call when it creates a stack frame where as allocating memory from the heap takes a function call, but that is about it.
Comment