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

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

View Full Document Right Arrow Icon
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 defined 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 definition 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 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]
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online