DOC PREVIEW
UMD CMSC 330 - Discussion Material

This preview shows page 1 out of 3 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 3 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC330: Discussion Material (10/1)October 1, 20081) What langage does the following grammar generate:S → aSbS | bSaS | Answer: The set of all strings with an equal number of a’s and b’s.2)a) Give the grammar that generates the language of the regular expression: 0*1(0 | 1)*Answer:S → A1BA → 0A | B → 0B | 1B | b) Give the leftmost and rightmost derivations of the following strings using the grammar from part a):i) 1001Answer:Leftmost: S → A1B → 1B → 10B → 100B → 1001B → 1001Rightmost: S → A1B → A10B → A100B → A1001B → A1001 → 1001ii) 00011Answer:Leftmost: S → A1B → 0A1B → 00A1B → 000A1B → 0001B → 00011B → 00011Rightmost: S → A1B → A11B → A11 → A011 → A0011 → A00011 → 00011c) Give the parse trees for the strings in part b).i) Answer:1ii) Answer:3) Design a context free grammar for the following language: {aibjck| i 6= j or j 6= k}Answer:S → RC | ATR → aRb | XX → aA | bBT → bT c | YY → bB | cCA → aA | B → bB | C → cC | Note: The important productions rules here are for the symbols R and T. R enforces the constraint i 6= jand T enforces the constraint j 6= k. The start symbol just ensures that one or the other must be true forthe string to be in the language of this grammar.4) Given the following grammar:S → aS | aSb | a) Is this grammar ambiguous? Why?Answer: Yes. The string aab has two parse tree s, leftmost derivations, and rightmost derivations.b) Redesign the grammar to be unambiguous.Answer:S → aSb | AA → Aa | Note: This is the grammar for the language ambn| m ≥ n5) Construct a NFA for the following grammar:S → aA | BA → aaBB → bB | a2Answer:Note: The grammar must be right or left-linear to perform this conversion. This grammar is


View Full Document

UMD CMSC 330 - Discussion Material

Documents in this Course
Exam #1

Exam #1

6 pages

Quiz #1

Quiz #1

2 pages

Midterm 2

Midterm 2

12 pages

Exam #2

Exam #2

7 pages

Ocaml

Ocaml

7 pages

Parsing

Parsing

38 pages

Threads

Threads

12 pages

Ruby

Ruby

7 pages

Quiz #3

Quiz #3

2 pages

Threads

Threads

7 pages

Quiz #4

Quiz #4

2 pages

Exam #2

Exam #2

6 pages

Exam #1

Exam #1

6 pages

Threads

Threads

34 pages

Quiz #4

Quiz #4

2 pages

Threads

Threads

26 pages

Exam #2

Exam #2

9 pages

Exam #2

Exam #2

6 pages

Load more
Download Discussion Material
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Discussion Material and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Discussion Material 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?