Q7Data Structures
Question
2 marks
Differentiate between static and Dynamic memory allocation.
Answer
Static allocation occurs during compilation with fixed sizes, whereas dynamic allocation occurs at runtime with adaptable sizes.
Static memory allocation strictly occurs during the software compilation phase, permanently reserving a rigidly fixed block of memory that cannot be subsequently resized (e.g., standard arrays). Dynamic memory allocation occurs flexibly during runtime execution, allowing software to dynamically request, resize, and explicitly free memory blocks on the heap as operational demands fluctuate (e.g., using malloc() or new).