



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Department of Electrical Engineering and Computer Sciences Computer Science Division
CS 164 P. N. Hilfinger Spring 2008
CS 164: Test #
Name: ________________________________________________ Login: _________
You have fifty minutes to complete this test. Please put your login on each sheet, as indicated, in case pages get separated. Answer all questions in the space provided on the exam paper. Show all work (but be sure to indicate your answers clearly.) The exam is worth a total of 20+ points (out of the total of 200), distributed as indicated on the individual questions. You may use any notes or books you please––anything unresponsive. We suggest that you read all questions before trying to answer any of them and work first on those about which you feel most confident. You should have 4 problems on 4 pages.
1. [6 points] Consider a really simplified set of regular expressions (call them RSREs) consisting of letters ‘a’ and ‘b’, concatenation, union (using the symbol ‘|’), epsilon (represented by the letter e), and Kleene star, but without parentheses. So, for example,
a ab ab | b | ba*
are valid RSREs.
a. Write a regular expression that recognizes RSREs. Use just the basic operators supplied by Flex or JFlex.
b. Draw a DFA that recognizes RSREs.
3. [1 point] I noticed that a certain kind of prepackaged snack sold in our local coffee shops has the slogan “The ones you remember,” which I thought was mildly clever. Why? 4. [8 points] Consider the parse tree below. All terminal symbols are written at the same level on the bottom row.
a. Show as much of the grammar as one can deduce from this parse tree.
More questions on the next page
b. Show a reverse rightmost derivation corresponding to this tree, as performed by a shift-reduce parser. (However, you need not mention the shifts and reductions, just the sentential forms that get you back to the start symbol from the input).
c. Show that the grammar is ambiguous by giving a string that has (at least) two parses and giving two distinct parse trees for it.
Continued on next page.