EECS 483 - Fall 2003 Exam 1: Computer Science Problems - Prof. Scott Mahlke, Exams of Electrical and Electronics Engineering

The university of michigan eecs 483 fall 2003 exam 1 for computer science. The exam consists of 12 questions divided into two parts: short problems and design problems. The short problems section includes questions on regular expressions, parsing, and context-free grammars. The design problems section includes questions on constructing abstract syntax trees, identifying errors in code segments, and converting grammars to ll(1) form. Students are required to show their work and the exam is open book and open notes.

Typology: Exams

Pre 2010

Uploaded on 09/02/2009

koofers-user-p82
koofers-user-p82 🇺🇸

10 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Page 1 of 10
EECS 483 – Fall 2003 –Exam 1
Monday, October 27, 2003
2 hours: open book, open notes
Name: ______________________________________
Please sign indicating that you have upheld the Engineering Honor Code at the
University of Michigan.
"I have neither given nor received aid on this examination."
Signature: ______________________________________
There are 12 questions divided into 2 sections. The point value for each question is
specified with that question. Please show your work unless the answer is obvious. If you
need more space, use the back side of the exam sheets.
Part I: Short Problems
8 questions, 55 pts total Score:_____
Part II: Design Problems
4 questions, 95 pts total Score:_____
Total (150 possible): _______
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download EECS 483 - Fall 2003 Exam 1: Computer Science Problems - Prof. Scott Mahlke and more Exams Electrical and Electronics Engineering in PDF only on Docsity!

EECS 483 – Fall 2003 –Exam 1

Monday, October 27, 2003

2 hours: open book, open notes

Name: ______________________________________

Please sign indicating that you have upheld the Engineering Honor Code at the University of Michigan.

"I have neither given nor received aid on this examination."

Signature: ______________________________________

There are 12 questions divided into 2 sections. The point value for each question is specified with that question. Please show your work unless the answer is obvious. If you need more space, use the back side of the exam sheets.

Part I: Short Problems 8 questions, 55 pts total Score:_____

Part II: Design Problems 4 questions, 95 pts total Score:_____

Total (150 possible): _______

Part I. Short Answer Problems (Questions 1-8)

  1. Construct a regular expression over the alphabet {a,b,c} for the strings that are at least 3 characters in length and end with an ‘a’. (5 pts)
  2. One way to describe top-down verses bottom-up parsing is to say that one focuses on “generating strings” and the other on “recognizing strings” in the language. Which description best matches each form of parsing. Explain your answer in 1 or 2 sentences. (5 pts)

3 A context free grammar is capable of representing more languages than a regular expression. What is the major reason for this? (5 pts)

  1. Write a grammar to parse all strings consisting of the symbols {a,b,c,d,e} of the form: (10 pts) anb2mcmdneo^ , where m, n, o are >= 0
  2. Consider the following fragment of a possible solution grammar for C--:

stmt: IF OP_PAR arith_expr CL_PAR OP_BCS decls statements CL_BCS { ... } | IF_OP_PAR arith_expr CL_PAR OP_BCS decls statements CL_BCS ELSE OP_BCS decls statements CL_BCS { ... } ... ;

There is a shift/reduce error in the above grammar when parsing “if (arith_expr)” as the grammar does not know whether to shift and look for the corresponding “else” or to reduce and just parse the “if”. However, bison does not generate an error, why is this? (5 pts)

  1. Which is capable of parsing a larger set of languages, LR(0) or SLR? Explain your answer. (5 pts)

Part II. Design Problems (Questions 9-13)

9. Regular Expressions (20 pts)

Consider the following regular expression: a((b|a)(c|d)+)*

(a). Construct the NFA for this regular expression. (10 pts)

(b). Convert the constructed NFA to a DFA. (10 pts)

Problem 10 – Continued

(c). Construct the FIRST and FOLLOW sets for each non-terminal (S, A, B, C) on the following LL(1) grammar. (15 pts) S Æ AB A Æ bC B Æ aAB | ε C Æ (S) | c

11. Grammars and Parsing (20 pts)

Consider the following grammar: E Æ E + T | T T Æ TF | F F Æ F* | a | b (Note * is not the closure operator!)

(a). Construct the LR(0) DFA for this grammar. (15 pts)

(b). Are there any shift/reduce conflicts in the parsing table that would result from the DFA constructed above. Explain your answer. Note that you do not need to construct the parse table. (5 pts)

Problem 12 - Continued

(b). Is the following expression well-typed in a particular context? If so, indicate the result type. Explain your answer. (5 pts) pop(push(x,y+5))

(c). Is the following expression well-typed in a particular context? If so, indicate the result type. Explain your answer. (5 pts) push(newstack(int), top(x)) + push(y,empty(z))