wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Theory of Computation

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.

Correct hierarchical relationship among context- free, right-linear, and context-sensitive language is

a)

context-free ⊂ right-linear ⊂ context-sensitive

b)

context-free ⊂ context-sensitive ⊂ right-linear

c)

context-sensitive ⊂ right-inear ⊂context-free

d)

right-linear ⊂context-free ⊂context-sensitive

2.

In the following grammar :


x : : = x ⊕ y | 4

y : : = z * y I 2

z : : = id

which of the following is true ?

a)

⊕ is left associative while * is right associative

b)

Both ⊕ and * are left associative

c)

⊕ is right associative while * is left associative

d)

None of these

3.

Which of the following CFG's can't be simulated by an FSM ?

a)

S --> Sa | b

b)

S --> aSb | ab

c)

S --> abX, X --> cY, Y --> d | aX

d)

None of these

4.

Which of the following statements is correct?

a)

A = { If an bn | n = 0,1, 2, 3 ..} is regular language

b)

Set B of all strings of equal number of a's and b's deines a regular language

c)

L (A* B*)∩ B gives the set A

d)

None of these

5.

A class of language that is closed under

a)

union and complementation has to be closed under intersection

b)

intersection and complement has to be closed under union

c)

union and intersection has to be closed under complementation

d)

both (A) and (B)

6.

The productions

E—>E+E

E—>E—E

E-->E*E

E —> E / E

E —> id

a)

generate an inherently ambiguous language

b)

generate an ambiguous language but not inherently so

c)

are unambiguous

d)

can generate all possible fixed length valid computation for carrying out addition, subtraction, multipication and division, which can be expressed in one expression

7.

Which of the folowing definitions below generates the same language as L, where

L = {xn yn such that n > = 1} ?

I. E —> xEy | xy

II. xy | (x+ xyy+)

III .x+y+

a)

I only

b)

I and II

c)

II and III

d)

II only

8.

Following context free grammar

S —> aB | bA

A —>b | aS | bAA

B —> b | bS | aBB

generates strings of terminals that have

a)

equal number of a's and b's

b)

odd number of a's and odd number b's

c)

even number of a's and even number of b's

d)

odd number of a's and even number of a's

9.

The CFG

s---> as | bs | a | b

is equivalent to regular expression

a)

(a + b)

b)

(a + b) (a + b)*

c)

C.(a + b) (a + b)

d)

None of these

10.

Consider the grammar :

S —> ABCc | Abc

BA —> AB

Bb —> bb

Ab —> ab

Aa —> aa

Which of the following sentences can be derived by this grammar

a)

abc

b)

aab

c)

abcc

d)

abbb

11.

Pumping lemma is generally used for proving that

a)

given grammar is regular

b)

given grammar is not regular

c)

whether two given regular expressions are equivalent or not

d)

None of these

12.

The language of all words with at least 2 a's can be described by the regular expression

a)

(ab)*a and a (ba)*

b)

(a + b)* ab* a (a + b)*

c)

b* ab* a (a + b)*

d)

all of these

13.

Any string of terminals that can be generated by the following CFG is

S-> XY

X--> aX | bX | a

Y-> Ya | Yb | a

a)

has atleast one 'b'

b)

should end in a 'a'

c)

has no consecutive a's or b's

d)

has atleast two a's

14.

If Σ = (0, 1), L = Σ* and R = (0n 1nsuch that n > 0 )

then languages L ∪ R and R respectively are

a)

Regular, Regular

b)

Regular, Not regular

c)

Not regular, Not regular

d)

None of these

15.

Which of the following statement is correct?

a)

All languages can not be generated by CFG

b)

Any regular language has an equivalent CFG

c)

Some non regular languages can't be generated by CFG

d)

both (b) and (c)

16.

If L1 and L2 are context free language and R a regular set, then which one of the languages below is not necessarily a context free language?

a)

L1 L2

b)

L1 ∩ L2

c)

L1 ∩ R

d)

L1 ∪ L2

17.

Consider a grammar with the following productions


S--> aab | bac | aB

S --> α S | b

S --> α b b | ab

Sα --> bdb | b


The above grammar is

a)

Context free

b)

regular

c)

context sensitive

d)

LR ( k )

18.

A given grammar is called ambiguous if

a)

two or more productions have the same non-terminal on the left hand side

b)

a derivation tree has more than one associated sentence

c)

there is a sentence with more than one derivation tree corresponding to it

d)

brackets are not present in the grammar

19.

The grammars G = ( { s }, { 0, 1 }, p , s)

where p = (s —> 0S1, S —> OS, S —> S1, S —>0} is a

a)

recursively enumerable language

b)

regular language

c)

context-sensitive language

d)

context-free language

20.

The logic of pumping lemma is a good example of

a)

pigeon-hole principle

b)

divide-and-conquer technique

c)

recursion

d)

iteration