sample-final

# sample-final - CSE 460 Sample Final Exam Fall Semester 2007...

This preview shows pages 1–4. Sign up to view the full content.

CSE 460 - Sample Final Exam Fall Semester, 2007 Name The type A, B, C, D points on this exam sum to 13, 26, 17, 22. There are 3 extra credit points that can be applied to any category. 1. Consider the following grammar G 1 deﬁned in abbreviated format. E E + E | E * E | 4 | 5 | 6 | 7 Given the following leftmost derivation of the string 4+5 * 6+7, answer the following questions. E E + E E * E + E E + E * E + E 4+ E * E + E 4+5 * E + E 4+5 * 6+ E 4 + 5 * 6 + 7. (a) Draw the corresponding parse tree. [2, A] (b) Draw the corresponding rightmost derivation. [2, A] (c) Give the numerical value of 4 + 5 * 6 + 7 implied by the above parse tree. [1,A] (d) Give an alternative leftmost derivation for 4 + 5 * 6 + 7. [2,A] (e) Correct the following incorrect deﬁnition of an ambiguous CFG G . [2,A] A CFG G is ambiguous if G has two or more distinct derivations for some string x L ( G ). 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2. Given the following two grammars G 1 and G 2 , apply the constructions we have seen in class to generate a new grammar G 3 such that L ( G 3 ) = ( L ( G 1 ) L ( G 2 )) * . Specify G 3 completely (not in abbreviated format). [4, B] G 1 G 2 V 1 = { S,T } V 2 = { S,T } Σ = { a,b } Σ = { a,b } Start variable S 1 is S Start variable S 2 is T P 1 = S aSa | aT, T bbST | b P 2 = S bT | aS, T ST | abab Grammar G 3 V 3 = Σ = { a,b } Start variable S 3 is P 3 = 3. Suppose we apply the construction covered in class to construct an FSA M 2 from an NFA M 1 with 10 total states and 3 accepting states such that L ( M 2 ) = L ( M 1 ). (a) How many total states does M 2 have? [1, B] (b) How many accepting states does M 2 have? [1, B] 2
(a) Identify all the nullable variables in the following grammar G 1 with start variable S . [1,B] S ABCD | a A BCD | BC | b B CC C a | b | λ D aa | DD Nullable variables: (b) Apply the algorithms from class to produce a grammar G 2 such that L ( G 2 ) = L ( G 1 ) - { λ } where G 2 has no λ -productions. [1,B] (c) Apply the algorithms from class to produce a grammar G 3 such that L ( G 3 ) = L ( G 2 ) by eliminating the unit productions from the grammar G 2 . [1,B]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

sample-final - CSE 460 Sample Final Exam Fall Semester 2007...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online