Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4 Probem_Heap vs. Stack Briefly address the following questions (2-3 sentences):

ID: 3600364 • Letter: 4

Question

4 Probem_Heap vs. Stack Briefly address the following questions (2-3 sentences): 1. Why can we not dynamically allocate objects on the stack? That way, we would avoid having to deal with the heap 2. Your language definition allows the runtime stack to contain at most one stack frame for each procedure at any point in time during program execution. Do you still need a runtime stack? 3. Could we change our runtime environment to allocate all stack frames on the heap? If yes, what are the advantages / disadvantages?

Explanation / Answer

Answer:

1. We cannot dynamically allocate objects into the stack because it is risky . It is risky in the sense as it causes stack overflow. We should avoid heaps because, in heap, the allocated size is fixed.In stack, you can allocate as much as you want until the RAM gets full and explode and destroy the world.If you dynamically allocate object, then the memory allocation is out of control.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote