The Gateway to Computer Science Excellence
+3 votes
398 views

Consider the following statements:
S1 : Static allocation can not support recursive function.
S2 : Stack allocation can support pointers but can not deallocate storage at run-time.
S3 : Heap allocation can support pointers and it can allocate or deallocate storage at run-time.
Which of the above statements are true?

A.) S1 and S2

B.) S2 and S3

C.) S3 and S1

D.) S1, S2, and S3

in Compiler Design by Junior (823 points)
closed by | 398 views
0
Statements S1, S2 and S3. all are correct.

recursion requires stack

stack can support pointers but can't support runtime allocation heap can support it.
0
I too thought that but answer they gave is C.

this is their argument for S2

" Stack allocation can support pointers and with help of pointers it can allocate and deallocate dynamic variables and hence can manage runtime storage. "
0
Someone please answer.

1 Answer

0 votes
ANS is C
FOR S2
int **p = new int*;

In this case you reserve a portion of memory for a pointer to int in the heap, but the pointer that can reference such location is still a stack variable.

by (141 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,597 answers
195,840 comments
102,147 users