885 views
0 votes
0 votes
Consider the following statements :
S1: Variables/function calls have nested lifetime in case of stack allocation.
S2: Variables/function calls have arbitrary lifetime in case of heap allocation.
Which of the following statement  is/are true?

1 Answer

2 votes
2 votes
S1: Variables/function calls have nested lifetime in case of stack allocation.

It cannot be true since in stack allocation the variables or functions taking space are automatically deleted.

Nested lifetime means if the variable is allocated space in a function then other nested functions calls can delete that variable which is not true with stack allocation.

So S1 is wrong.

S2: Variables/function calls have arbitrary lifetime in case of heap allocation.

Yes, it can be said that they have arbitrary lifetime because the user can deallocate space anytime and the space allocated needs to be explicitly deallocated.

So, S2 is True.

Correct me if wrong ??????

Related questions

0 votes
0 votes
1 answer
1
set2018 asked Dec 10, 2017
1,986 views
1)S1 is regular but not S22)S2 is regular but not S13)S1 and S2 are not regular4)S1 and S2 are regular
1 votes
1 votes
1 answer
2
2 votes
2 votes
3 answers
3
techbrk3 asked Nov 12, 2017
1,904 views
$(a^+)^∗=(a^∗)^+$$(a^+)^+=aa^+$$(a^∗)^∗=a^∗$$aa^+ +a=a^+$
0 votes
0 votes
1 answer
4
sajalsjddn asked May 29, 2016
867 views
(A) Each one can simulate the other(B) The turing machines always halts which represents all C programs(C) The C programs that always halt can simulate all turing machine...