Cse 3103
Cse 3103
Section-A
Q.2 (a) What is the problem occur in triples? What is the solution for it? 1
(b) Find the error from the following code also mention that what kind of error is it? 3
#include<stdio.h>
#include<math.h>
int main()
{ int#MYVAR, hello@world;
scanf(“%i%i”, #MYVAR, hello@world);
if(#MYVAR);
{
printf(“This should print \n”);
}
int diameter = 5;
double area;
CONST int PI = acos(-1.0);
area = PI * (diameter/2) * (diameter/2);
printf(“%d”, area);
for(int i = 0, i < 100, i++ );
printf(“This should also print”);
return 5;
}
(c) Find out First and Follow from the following production rule. 6
S aBDh
B cC/Bwxc/BEghe
C bC/Ɛ
D EF/Dc/Djl
E g/Ɛ
F f/Ɛ
Q.3 (a) What is the main idea behind using two Buffer? 2
(b) Remove left factoring from the following grammar. 5
(i) S a/ab/abc/abcd
(ii) S SaSSbS/aSaSb/aSbb/b
(iii) E E + T/T
(iv) S E+ T/asvd/gfds/uhvv
(v) h +-*ghT/T+ -jh/ +-hg/T+hgu
1/2
(i) Using the definition of LL(1), explain why the grammar is or not LL(1)
(ii) Show whether the grammar is or is not SLR(1). (Treat “Ɛ” as a terminal)
Section-B
Q.4 (a) What is non-determinism? 2
(b) Write a code for Fibonacci series (using loop) in any language. Then draw control flow 5
graph for that code.
(c) Judge the effects of global optimization with proper example. 3
Q.6 (a) Write the difference between high-level and low-level IR. 2
(b) Write a regular expression for an identifier, Phone number and email address. 3
(c) Write down the optimized code for the following code. And also mention the name of 5
optimization technique.
(i) S1 = 4xi
S2 = a[S1]
S3 = 4xj
S4 = 4xi
S5 = n
S6 = b[S4] + S5
(ii) for (int j = 0 ; j < n ; j++)
{
x = y+z
a[j] = 6*j;
}
(iii) i=0
if(i = = 1)
{
a = x +5;
}
(iv) B = A*2
2/2