| NAME (print clearly): |
| Question | Mark |
| 1. Dynamic binding [12 marks] | |
| 2. Recursion/tail recursion [12 marks] | |
| 3. Subroutines/parameters [12 marks] | |
| 4. Macro systems [12 marks] | |
| 5. Basic scanning and parsing [12 marks] | |
| 6. Augmented (context sensitive) grammars [12 marks] | |
| 7. Type conversions and compatibility [12 marks] | |
| Wrote your name at the top :) [1 mark] | |
| Exam Total [85 marks] |
Fibonacci(N) if N < 3 return 1 else return Fibonacci(N-1) + Fibonacci(N-2)Explain why this algorithm is not tail recursive, and outline a tail-recursive alternative.
Second, provide a context free grammar for the programming language with the structure described below. Assume we already have definitions for token types IDENTIFIER, DECLARED, EQUALS, LITERAL, WRITE, PLUS, MINUS, DIVIDE, TIMES, END.