Log In
2 votes
Which of following is correct?

1). Drawback with static allocation is that it does not support recursion.

2). Drawback with stack allocation is that, when function completes its execution it will be popped out from stack..

3). Both are correct

4).None of above
in Compiler Design 329 views

2 Answers

5 votes
Best answer
1. is correct and recursion can never be done with static allocation.

2. is a bit ambiguous. But assuming a functional language feature, this is also true. In order to return a function, its activation record must be alive even after function run. So, activation record is created on heap and not on stack for these languages.

selected by
Give a clear explanation for your answer please. The stack supports for LIFO then the function whenever completed it should pop the function is it right?

2 option seems to be advantageous. It saves memory thus efficiency?

It depends from what perspective we look at- that is why I told "ambiguous" - it won't be asked such in GATE. This is like saying Java is better than C- each has its advantages.

Putting activation record on stack and regaining memory is best for performance and efficiency. But it lacks flexibility in the sense that a function can no longer be returned by another function - a feature needed for functional language. I guess most of you (even me) have not programmed in functional language and hence cannot understand more on that side. If interested you can see Haswell or even lambda functions in C++11.
0 votes
What is ans???

any one explain pllz???

Related questions

1 vote
1 answer
1.Class of grammar that will parse using LR method is proper subset of class of grammar that will parse with predictive parser . 2. LR Parser can be constructed to recognize virtually all programming language constructs for which CFG can be written . Please give valid justification for each point even if it is false
asked Apr 30, 2018 in Compiler Design radha gogia 326 views
3 votes
3 answers
Consider the grammar G' given below: S → aSa | bSb | a | b | ϵ Which of the following option is incorrect? G is ambiguous G is unambiguous G generates palindrome strings There exists only one left most derivation for a given string. the grammar does not has ... ambigous??but i am getting only on eparse tree for any string. but,if a grammar needs left factoring then grammar is ambigous..right??
asked Dec 10, 2016 in Compiler Design Akriti sood 449 views
0 votes
0 answers
Which of the following statement/s is/are false for the following language: L = {am bn cq | m = n or n = q, m > 0, n > 0, q > 0} S1: The language can be parsed by any LR(K) parsers for any value of K. S2: The language cannot be recognized by deterministic PDA. Only S2 Only S1 Both S1 and S2 Neither S1 nor S2
asked Dec 10, 2016 in Compiler Design Akriti sood 753 views
2 votes
1 answer
Which of the following symbol table implementation is based on the property of locality of reference? Self-organizing list Hash tree Search tree Array
asked Dec 8, 2016 in Compiler Design Akriti sood 3.8k views