0% found this document useful (0 votes)
112 views

Do Not Open Until Instructed To Do So: CS 205 Quiz #9B - Nov 29, 2012

This document appears to be a quiz for a CS 205 class. It instructs students not to open the quiz until instructed to do so. It then contains multiple questions related to formal language theory, including questions about phrase-structure grammars, context-sensitive/context-free/regular grammars, derivations in grammars, and constructing grammars. The document provides space for students to show their work and answers.

Uploaded by

Paul Jones
Copyright
© Attribution Non-Commercial (BY-NC)
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)
112 views

Do Not Open Until Instructed To Do So: CS 205 Quiz #9B - Nov 29, 2012

This document appears to be a quiz for a CS 205 class. It instructs students not to open the quiz until instructed to do so. It then contains multiple questions related to formal language theory, including questions about phrase-structure grammars, context-sensitive/context-free/regular grammars, derivations in grammars, and constructing grammars. The document provides space for students to show their work and answers.

Uploaded by

Paul Jones
Copyright
© Attribution Non-Commercial (BY-NC)
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
You are on page 1/ 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

2. Answer the questions below.


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

______________ e) S 1AB, AB 0B, B 0, A 1B

______________ f) S 0B, B 1A, B 0, A 0B

______________ g) S 1S11, S A, A 0A, A

______________ h) S 0S, S 1A, A , A 1A

______________ i) S 010, S 0SB0, 0B B0, 1B 11

______________ j) S 0S, S 1A, S 1, A 0A, A 1A, A 0, A 1

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

You might also like