0% found this document useful (0 votes)
30 views3 pages

CD Unit-IV Questions - MSWEC

The document contains a series of questions related to storage allocation strategies, activation records, runtime stacks, flow graphs, and various optimization techniques in programming. It covers topics such as code optimization, data flow analysis, and the construction of control flow graphs, along with examples and pseudocode. The questions are structured for an academic examination setting, focusing on the principles and applications of these concepts in computer science.

Uploaded by

vkrao1984
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

CD Unit-IV Questions - MSWEC

The document contains a series of questions related to storage allocation strategies, activation records, runtime stacks, flow graphs, and various optimization techniques in programming. It covers topics such as code optimization, data flow analysis, and the construction of control flow graphs, along with examples and pseudocode. The questions are structured for an academic examination setting, focusing on the principles and applications of these concepts in computer science.

Uploaded by

vkrao1984
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

MSWEC

CD Unit-V Questions
June 2023
1. a) Explain various storage allocation strategies with its merits and demerits.
b) Define activation records. Explain how it is related with runtime storage
allocation.
2. a) What is runtime stack? Explain the storage allocation strategies used for
recursive procedure calls.
b) What is a flow graph? Explain how flow graph can be constructed for a given
program.
Main()
{ int sum, n, i;
sum=0;
for i:=1 to n do
sum:=sum+i;
write(sum);
}
3. a) What are the principles associated with designing calling sequences and the
layout of activation records?
b) What is the role of code Optimizer in compiler? Is it a mandatory phase?
Explain the various sources of optimization.
4. a) Explain how data flow equations are set up and solved for improving code.
b) Discuss basic blocks and flow graphs with an example.
5. a) Give the general structure of an activation record? Explain the purpose of
each component involved in it.
b) Explain various machine independent code optimization techniques.
6. a) Write a short note on peephole optimization and various operations used in it.
b) Describe Loop unrolling? Describe its advantage with your own examples.
7. a) Explain static and stack storage allocations?
b) Translate the arithmetic expression a[i]=b*c-b*d into a syntax tree, quadruples
and triples.
8. a) Write pseudocode for finding sum of ‘n’ numbers. And identify basic blocks
then construct the flow graph for it. Explain the rules used for this.
b) Explain the following peephole optimization techniques;
i) Elimination of Redundant Code
ii) Elimination of Unreachable Code
Dec 2023
9. a) Explain briefly about storage organization. [7M]
b) Discuss briefly about Structure Preserving Transformations.
10. a) Describe in detail about Peephole Optimization.
b) What is a flow graph? Explain with suitable example.
June 2024
11. a) Explain the contents of an activation record with an example.
b) What is an induction variable and identify the induction variables in the
following statements in C
for( i=0,j=1,k=2,l=4 ; i< n ; i++){
j= j+2
k = k+3
l = l+4
sum = sum + i*j*k
}
12. a) Compare static, stack, dynamic storage allocation strategies
b) What is dead code elimination explain with an example
13. a) Consider the following intermediate code statements numbered from 1 to 12
1 i=0
2 if i<n goto 4
3 goto 11
4 t1 = 4*i
5 t2 = a[t1]
6 t3 = t2 + 1
7 t4 = 4*i
8 b[t4] = t3
9 i= i+1
10 goto 2
11 t5 = 4*i
12 b[t5] = 0
Construct a control flow graph for the given code and explain which of the 4*i
computation in statement 7 and statement 11 are redundant.
b) Explain with an example why static allocation strategy is not appropriate for
languages like C.
14. a) Draw the activation tree for the function call f(5) where definition of f is given
as follows
int f(int n){
if n==0 return 0
else if n==1 return 1
else return f(n-1) + f(n-2)
}

b) Explain different loop optimizations with example


15. a) Show the contents of the activation record for the function call f(6) where
definition of f is given as follows and f is called from main function
int f(int n){
if n==0 return1
else returnn* f(n-1)
}
b) Explain in detail common sub expression elimination, copy propagation, dead
code elimination optimizations with examples.
16 . a) Explain the purpose of live variable data flow analysis with an example.
b) Write a brief note on structure preserving transfromations.
17. a) Explain the stack allocation strategy with an example.
b) Define basic block and write algorithm for constructing control flow graph
from the intermediate code.
18. Perform available expression analysis on the following intermediate code
statements numbered from 1 to 9
i) Argue whether a*b expression is available at statement 6 and
statement 8
ii) Argue whetherb*c expression is available at statement5 and
statement 9
1 x = a*b
2 y = b*c
3 if a>20 goto 6
4 z = a*b
5 w = b*c
6 p = a*b
7 a = a+20
8 q = a*b
9 r = b*c
Nov-2024
19. a) Describe about the stack allocation in memory management.
b) Describe the organization of hash based symbol tables.
20. a) Describe in detail about heap management.
b) Write about calling sequences in Stack allocation of space.

You might also like