CS2111 Exam hints


Exam technique


Exam format & question style

The format is slightly unusual: You must answer question one (in section A), plus any 2 of questions two, three and four (in section B). Like most (but maybe not all) 2nd year CS exams, you have to answer 3 questions in 2 hours, and each question is worth 20 marks. The whole exam counts for 75% of your final course-unit mark, with the lab counting as the other 25%.

For questions three and four you can answer any 2 of the 3 parts. (Questions one and two have no optional parts.)

The first, compulsory, question is about the use of lex and yacc, and is similar to the labs.

Possible questions

I wrote this part several years ago, when there were no previous papers to show students, but it is still relevant, although I have probably simplified the questions a bit since then. Don't expect any actual exam question to exactly match anything I say below, but it should give you an idea of the sort of questions I might ask.

There will be at least one question about implementation and the use of Lex and Yacc (i.e. handouts 2-8, 10, 19). If you can do the lab exercises, you should be able to cope.

The other questions and part-questions will relate mainly to the content of the lectures. For any lecture (or parts or combinations of them), I might ask questions essentially of the form "tell me all you know about topic X", although I may not expect you to tell me everything in the lectures. This might be a complete question, or a question may consist of several parts like this (e.g. "answer 3 of the following 4 parts"), or it may be half of a question, where the other half is to draw some conclusions, or apply the concepts somehow. To give you a very vague idea of the kind of questions I might ask (but not the details, such as how much I expect you to answer for how many marks) here are some examples I made up just looking at the list of lectures:

What are precedence, associativity, etc. for operators?
How would you deal with them using Lex & Yacc?
What are they in C?

What are the legal forms of grammar rules for (or other inputs to) Lex (or Yacc)?
What can Yacc do that Lex can't & vice versa?

What are likely parse trees for some code fragments?
How would you build them?

What is wrong with your favourite programming language?
How would you correct the design?
How would this affect the implementation of a compiler for it?

How would you generate code for a typical register-based computer, giving examples?
How would your algorithm affect the way you built a compiler for the language?
Give an example of code optimisation?
How would incorporating this affect the way you built the compiler?

What are the primitive (or composite) types (or control structures, or scope and extent rules, or etc. etc.) you would expect in a programming language?
How does C measure up?
How would you redesign the language to include them?
How would this affect the implementation of a compiler for it?

How would you implement identifiers, or types, or type checking, or whatever in a typical compiler?