


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A computer science midterm examination for the university of california, berkeley's cs164 course in spring 1998. The examination covers topics such as parsing, pushdown automata, abstract classes, and java programming. Students are required to define terms, answer multiple choice questions, identify sentences recognized by a finite state automaton, construct parse trees, and determine which instance variables can be accessed using given objects.
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



(30 points) Define the following terms:
(10 points) Answer the following:
T F A pushdown automaton can recognize a language defined by a regular grammar. T F A bottom-up parser performs reductions in the same order as a rightmost derivation. T F A variable declared in Java to be a type Class can reference the object Object. T F Class variables cannot be defined in a Java abstract class. T F A nondeterministic fsa can recognize languages that a deterministic fsa cannot recognize.
(20 points) Answer the following questions given the fsa:
a) Identify which sentences are recognized by this automaton.
Yes No aab Yes No bbabca Yes No bcaabaaabaa
Computer Science 164 - Spring 98 Midterm Examination Professor L. Rowe 1
Yes No bbcb Yes No abbbbabbabca b) Show a left regular grammar that specifies the language recognized by the fsa. (Hint: write a grammar rule which would produce the fsa using the algorithm given in class.)
c) Describe in English the language recognized by the fsa.
(20 points) Given the following LR parser tables and grammar rules, answer the following questions.
a ( ) $ S L 0 s2 s3.. 1. 1... acc.. 2 r1 r1 r1 r.. 3 s2 s3.. 5 4 4 s2 s3 s6. 7. 5 r3 r3 r3 r.. 6 r2 r2 r2 r.. 7 r4 r4 r4 r..
The grammar is 1: S -> a 2: S -> '('L')' 3: L -> S 4: L -> LS a) Show the parse tree for the sentence "( ( a ( a ) ) )".
b) Show the parser configurations as it parses that input in the following table. You must use state numbers on the syntax stack. (Hint: 22 configurations are shown in the table -- the parse may take less than, more than, or equal to that number of steps.)
step stack input action 1 0 ( ( a ( a ) ) ) $ shift 3
2 0 3 ( a ( a ) ) ) $ shift 3
3 4
new C(); C ac = new D(); D ad = } }
a) Which instance variables can be accessed using the object ac in the method main?
b) Which instance variables can be accessed using the object ad in the method main?
c) Which instance variables can be accessed in the method called by D.f() in the method main?
Total: 100 points