Which of the following is an example of static memory allocation?
Answer: D
Correct answer: Array
An array declared with a fixed size has its storage settled at compile time, in the stack frame or the data segment according to where it is declared. Nothing is requested at run time and nothing is freed.
The other three are dynamic structures built from nodes obtained with malloc as they are needed. A stack and a queue can be implemented over a fixed array, but as abstract structures they grow and shrink, which is what places them on the dynamic side of the distinction.
Please log in or register to report this question.