# CS3800 SP11: Homework 05

Created: Fri 11 Feb 2011

Assigned: Fri 02-11-11
Due: Fri 02-18-11

## Instructions

1. Please review the grading policy outlined in the course information page.
2. On the first page of your solution write-up, you must make explicit which problems are to be graded for "regular credit", which problems are to be graded for "extra credit", and which problems you did not attempt. Please use a table something like the following
Problem 01 02 03 04 05 06 07 08 09 ...
Credit RC RC RC EC RC RC NA RC RC ...

where "RC" is "regular credit", "EC" is "extra credit", and "NA" is "not applicable" (not attempted). Failure to do so will result in an arbitrary set of problems being graded for regular credit, no problems being graded for extra credit, and a five percent penalty assessment.

3. You must also write down with whom you worked on the assignment. If this changes from problem to problem, then you should write down this information separately with each problem.

When a problem asks for a context-free grammar, you must describe what each variable in your context-free grammar does, in a manner similar to the solution given in the handout.

When you are asked to construct a PDA for a given language. You should give finite state diagrams for such PDAs, similar to those given in class and in Figures 2.15, 2.17, and 2.19 from the Sipser text.

To demonstrate that a given grammar is ambiguous, you must show multiple left-most (or right-most) derivations for a string in the given language. (See pp. 105-106 of the Sipser text.) To attach a "meaning" to any such derivation, you will likely need to consider the parse trees associated with these derivations.

## Problems

Required: 5 of the following 6 problems
Points: 20 pts per problem

1. Exercise 2.4 (b,c)

2. Exercise 2.6 (d)

• Exercise 2.4 (e)
• Construct a CFG for the following language:

{ai bj | i <= j <= 2i}

3. Exercises 2.9 and 2.10.

4. Give finite state diagrams for PDAs which accept the languages described in Exercises 2.4 (d) and 2.6 (c).

Hint: Make judicious use of non-determinism.

5. Problem 2.27 (a).

Hint: The ambiguity present in the grammar shown in Exercise 2.27 is due to the `if-then` and `if-then-else` statements. The ambiguity you will discover is referred to as the "dangling else" ambiguity.

### Switch to:

Harriet Fell
College of Computer Science, Northeastern University
360 Huntington Avenue #202WVH
Boston, MA 02115

Phone: (617) 373-2198 / Fax: (617) 373-5121

Last Updated:
The URL for this document is: http://www.ccs.neu.edu/home/fell/CS3800/Homeworks/hw.05.html