search
Log In
Redirected from merged question 199243
2 votes
326 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?

S1 and S2

S2 and S3

S3 and S1

d  S1, S2 and S3

in Compiler Design
edited by
326 views
1
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.
0
Ans C

Stack allocation supports pointers, true, and with that stack allocation happens when stack function is called ,so, once the function call is over memory is deallocated i.e. deallocation of storage at run time.

4 Answers

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.

0 votes
Answer should be D
0 votes

Answer D s1s2 s3 all are true

0 votes

TRUE   S1 : Static allocation can not support recursive function.

FALSE  S2 : Stack allocation can support pointers but can not deallocate storage at run-time.

Stack memory is allocated during compilation time execution. This is known as static memory allocation.

https://iq.opengenus.org/static-memory-allocation-c/

TRUE   S3 :  Heap allocation can support pointers and it can allocate or deallocate storage at run-time.

 

Related questions

1 vote
3 answers
1
504 views
Match the following with respect to activation record fields: A 1 → A, D; 2 → B, C B 1 → A, C; 2 → B, D C 1 → B, C; 2 → A, D D 1 → B, D; 2 → A, C Doubt:- Control link points to caller activation record.Can some one confirm?
asked Jan 25, 2018 in Compiler Design rahul sharma 5 504 views
0 votes
2 answers
2
221 views
The two basic operations that are often performed with the symbol table are: 1. Set and reset 2. Set and insert 3. Insert and lookup 4. Reset and lookup
asked Dec 27, 2018 in Compiler Design Prince Sindhiya 221 views
1 vote
1 answer
3
247 views
Which of the Following is True ? A. Symbol table Construction is during the analysis part of the Compiler. B. Type checking is Done during Syntax Analysis phase C. SDD with only synthesized attribute have an order of evaluation D. Both A and C Please Explain the C part only rest are easy :)
asked Oct 8, 2018 in Compiler Design Na462 247 views
1 vote
2 answers
4
235 views
can anyone tell broadly about "Arbitrary lifetime in case of heap allocation".
asked Mar 11, 2018 in Compiler Design The Technical Guy 235 views
...