You are on page 1of 7

CS 205 Quiz #9B Nov 29, 2012

NAME: __________________________________________________________________________

RUID:___________________________________________________________________________

Electronic Devices are not permitted during the quiz. These include but are not restricted to calculators,
computers and cell phones.
No communication between students or anyone outside of class is permitted during the quiz.
Textbooks, notes and any other written materials are not permitted during the quiz.

DO NOT OPEN UNTIL

INSTRUCTED TO DO SO

1. Let G be the phrase-structure grammar with vocabulary V = { A, B, 0, 1, S },

production set P = { S AB0, AB 1, A 0, B AB }, start symbol S, and
terminal element set T = { 0, 1 }. For each of the following, write True if it is derivable
from S, otherwise write False.

_____________________ a)

_____________________ b)

10

_____________________ c)

01

_____________________ d)

000

_____________________ e)

11

_____________________ f)

010

_____________________ g)

0000

_____________________ h)

0001

_____________________ i)

110

_____________________ j)

0010

a) Find a set of exactly 2 productions that produces {(11)n | n 0}.
Use only nonterminal S, where S is the start symbol.

b) Find a set of exactly 2 productions that produces {0n12n | n 0}.

Use only nonterminal S, where S is the start symbol.

c) Find a set of exactly 5 productions that produces {(01)21m0n | m 0 n 0}.

Use nonterminals S, A and B, where S is the start symbol.

3. Let V = { A, B, 0, 1, S } and T = { 0, 1 }. For each of the following production

sets P, determine whether G = (V, T, S, P) is a
A. Type 0 grammar, but not a type 1 grammar
B. Type 1 (context-sensitive) grammar, but not a type 2 grammar
C. Type 2 (context-free) grammar, but not a type 3 grammar
D. Type 3 (regular) grammar

______________ a) S A10, AB 0

______________ b) S B, A B, B A, B 1

______________ c) S AB, A 0B1, 0B1 0

______________ d) S 1A, A 1, S

4. Consider grammar G = (V, T, S, P) where V = { A, B, a, b, S } and

T = { a, b }. The set of productions P in Backus-Naur form are:
S ::= AA | B
A ::= aaA | aa
B ::= bB | b
Determine whether each of the following is derivable starting from S. Write True if it is derivable
and False if it is not derivable.

_____________________ a)

_____________________ b)

aa

_____________________ c)

aaaa

_____________________ d)

aaaaa

_____________________ e)

ab

_____________________ f)

aaaab

_____________________ g)

_____________________ h)

bb

_____________________ i)

bbbbb

_____________________ j)

5. Find a context-free grammar that generates the set of all strings over the alphabet {0, 1} such
that 0 appears twice as many times as 1. List the productions in the space provided below. Use only
four productions and only one nonterminal, S.

Scratch Paper