DOC PREVIEW
UMD CMSC 330 - Practice Problems 2

This preview shows page 1 out of 2 pages.

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

Unformatted text preview:

CMSC 330 Spring 2011 Practice Problems 2 1. For each regular expression r below, (i) say whether or not r✓ holds and (ii) give the transitions of r. a. r = a* b. r = (a|ab)*a c. r = a*(ba*ba*)* 2. For each regular expression in Question 1 i. Reduce the RE to an NFA using the algorithm described in class. ii. Reduce the resulting NFA to a DFA using the subset algorithm. iii. Show whether the DFA accepts / rejects the strings “aba”, “aa”, “bbabb”. 3. Context-Free Grammars a. List the 4 components of a context-free grammar. b. Describe the relationship between terminals, non-terminals, and productions. c. Define ambiguity. d. Describe the difference between scanning & parsing. 4. Describing Grammars a. Describe the language accepted by the following grammar: S → abS | a b. Describe the language accepted by the following grammar: S → aSb | ε c. Describe the language accepted by the following grammar: S → bSb | A A → aA | ε d. Describe the language accepted by the following grammar: S → AS | B A → aAc | Aa | ε B→ bBb | ε e. Describe the language accepted by the following grammar: S → S and S | S or S | (S) | true | false f. Which of the previous grammars are left recursive? g. Which of the previous grammars are right recursive? h. Which of the previous grammars are ambiguous? Provide proof. 5. Creating Grammars a. Write a grammar for axby, where x = y b. Write a grammar for axby, where x > y c. Write a grammar for axby, where x = 2y d. Write a grammar for axbyaz, where z = x+y e. Write a grammar for axbyaz, where z = x-y f. Write a grammar for all strings of a and b that are palindromes. g. Write a grammar for all strings of a and b that include the substring baa.h. Write a grammar for all strings of a and b with an odd number of a’s and an odd number of b’s. i. Write a grammar for the set of regular expressions over the alphabet {a, b}. j. Which of your grammars are ambiguous? Can you come up with an unambiguous grammar that accepts the same language? 6. Derivations, Parse Trees, Precedence and Associativity For the following grammar: S → S and S | true a. List 4 derivations for the string “true and true and true”. b. Label each derivation as left-most, right-most, or neither. c. List the parse tree for each derivation d. What is implied about the associativity of “and” for each parse tree? For the following grammar: S → S and S | S or S | true e. List all parse trees for the string “true and true or true” f. What is implied about the precedence/associativity of “and” and “or” for each parse tree? g. Rewrite the grammar so that “and” has higher precedence than “or” and is right


View Full Document

UMD CMSC 330 - Practice Problems 2

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 Practice Problems 2
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 Practice Problems 2 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 Practice Problems 2 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?