wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Complier design

Total questions: 30

Worksheet time: 57mins

Name
Class
Date
1.

Which of the following grammar can be converted in LL(1) parser ?

a)

Grammar contain Left recursion

b)

Grammar contain Left factoring

c)

Grammar contain Left Factoring and right recursion

d)

None of the above

2.

Considering LALR(1) has n state for grammar, which of the following false

a)

SLR will have n state

b)

CLR will have exaclty n state

c)

SLR will have n state

d)

CLR may or may not have n state

3.

The following grammar is:

S--> Aa/bAC/dc/bda

A-->d

a)

Not SLR(1) and not CLR(1)

b)

CLR(1) but not SLR (1)

c)

SLR (1) but not CLR (1)

d)

SLR (1) and CLR (1)

4.

Consider the following grammer:

S-->aB/aAb , A-->bAa/a , B-->aB / ε .

How many back track are required to generate the string "ab" from the above grammar

a)

Nil

b)

1

c)

2

d)

3

5.

Consider the statement:

P=Q+R*60.

How many tokens are:

a)

6

b)

7

c)

8

d)

9

6.

Grammar:

E--> TE' ,

E'-->ε/+TE' ,

T--> FT',

T'--> ε/*FT' ,

F--> a / [E].

What is the first (E)

a)

+, *

b)

[ , ε

c)

] , ε

d)

a,[

7.

In term of deadlock, What is safe sequence ?

a)

Sequence, where the chances of deadlock in the future

b)

Sequence, where chances of deadlock is none

c)

Sequence, where the deadlokc is already happed

d)

Sequence, where OS remove the process

8.

The number of token generated by the lexical analyzer for the following program:

void main ()

{

print ("Hello world")

// To tell the world "hello"

}

a)

9

b)

10

c)

11

d)

17

9.

The system shares 9 instance of resource R. The following scenario:

"P1 is currently holding 3,P2 is currently holding 1,P2 is currently holding 3 ".

Which of the follwowing is the best description of current scenario.

a)

Deadlock but safe

b)

Deadlock but unsafe

c)

No deadlock

d)

Can't say

10.

The banker algorithms used for

a)

Deadlock detection

b)

Deadlock avoidance

c)

Deadllock recovery

d)

Deadlock prevention

11.

The time complexity of Banker algorithms is

Where "n" is number of process

a)

O( n2n^2  )

b)

O( n3n^3  )

c)

O( 2n2^n  )

d)

O(log n)

12.

The best descriobed statement for Wait-for-graph

a)

It is used to prevent the deadlock

b)

To check the dependency of between the process and resources

c)

To check the dependency of between the processes

d)

To solve the deadlock for multiple instances

13.

Consider the P_0, P_1, P_2, and P_3 process with resources A,B,C and D with maximum instances of 10, 4, 9 and 6. The follwing scenario expains the process allocatiaon and maximum resouces (in term of A,B,C,D)

P_0---> 2,1,2,0 (Allocated resources)----> 4,1,3,2 ( Max resources )

P_1---> 1,0,0,2 (Allocated resources) ----> 4,1,0,3 ( Max resources )

P_2---> 2,0,2,1 (Allocated resources)----> 5,4,4,1 ( Max resources )

P_3---> 2,3,4,1 (Allocated resources)----> 3,3,6,6 ( Max resources )

What is the safe sequence

a)

P_0, P_1, P_3, and P_2

b)

P_0, P_1, P_2, and P_3

c)

P_0, P_1, P_3, and P_3

d)

P_0, P_2, P_3, and P_1

14.

The following grammar:

S--> aXCd

X-->a/ ϵ\epsilon  

C--->a/d

Which of the follwing stament is true

a)

first (S)={a,d}

b)

follow(S)={ ϵ\epsilon  ,$}

c)

This is not LL(1) grammar

d)

This is LL(1) Grammar

15.

Which of the follwing statement is True for LALR parser

a)

It detect recursion and remove it

b)

It detect left factoring and remove it

c)

It resolve Reduce-reduce conflict only

d)

It resolve Shif-reduce and reduce-reduce conflict

16.

Grammar: X-->SSS/(S)/ ϵ\epsilon   is not suitable for parsing because the grammar is

a)

Left recursive

b)

Right Recursive

c)

Ambiguious

d)

None of the above

17.

In the following statement: a=b*c+d*e.

Compiler generates 3-address code for the above expression. The total number of temporary variables requried are

a)

4

b)

5

c)

6

d)

Can't generate three address code

18.

In the operator precedence rule, the + has highest precedence and right associative than -(minus) and * (multiplication). The - (minus) has high precedence and left associative than * . Finally * is right associative. Then compute the following expression :

2*3*4+5+9-1-2

a)

360

b)

361

c)

320

d)

160

19.

The following statement:

A: Every regular grammar is LL(1)

B: Every regular expression is LR(1)

Which of the following stament is True

a)

A is true and B is False

b)

A is True and B is True

c)

A is False, B is True

d)

A is False and B is False

20.

The main purpose of Lexical analyser

a)

Improve the register allocation

b)

The split whole inofrmation into small chunk

c)

To understand syntax of the code

d)

To undertand the meaning of code

21.

The Parsing is assoicated with

a)

Graph coloring

b)

DFA minimization

c)

Production tree

d)

Post-order Traversing

22.

Which of the follwing is not application of Syntax directed translation

a)

Creating Syntax tree

b)

Converting infix to Postfix

c)

Creating parsing Table

d)

Evaluating the arithmentic expression

23.

E-->E#T / T (# means *)

T--> T$F/F ($ means + )

F--> id (id means numerical value)

With the help of above grammar, calculate 2#3$5 using bottom up parsing

a)

16

b)

30

c)

25

d)

None of the above

24.

Consider the follwing grammar:

S--> FR

R--> *S/ ϵ\epsilon  

F-->id

In the LL(1) parsing table i.e. M , the entries of M[F,id] and M[R,$] are

a)

S-->FR

and

R--> ϵ\epsilon  

b)

S-->FR

and

noting

c)

Nothing

and

R-->S

d)

F-->id

and

R--> ϵ\epsilon  

25.

Given Grammar:

E-->E+T/E

T-->F-T/F

F-->id

Which one of the follwing is TRUE

a)

+ and - are left associative

b)

+ and - are right associative

c)

+ is right associative and

- is left associative

d)

- is right associative and

+ is left associative

26.

Grammar is

X-->xXYZ

Y--> y/z/ ϵ\epsilon  

Z-->x

What is follow of X

a)

{Y}

b)

{z}

c)

{y,z}

d)

{x,y,z}

27.

Which of the following statement is/are correct

A: Canonical LR is powerful than LL(1)

B: LL(4) is powerful than LL(2)

C: SLR is more powerfull than Canonical LR

a)

A and B

b)

A,B and C

c)

A and C

d)

A only

28.

Which of the following statement is True

a)

LALR is more powerful than CLR

b)

CLR is more powerful than LALR

c)

Both have same power

d)

CLR cannot be compared with LALR

29.

An LALR can have Shift-Reduce confict if and only if

a)

LR(0) have Shift-reduce conflict

b)

SLR have Shift-reduce conflict

c)

CLR have Shift-reduce conflict

d)

None of the above

30.

A grammer can be solve sovle by operator precedence parser if and only if

a)

It remove left recursion

b)

it remove left factoring

c)

In between two non-terminal there is a terminal

d)

None of the above