Present a right-most derivation for the string (a, ((a, a), (a, a)))

Explain how it is possible to “leak memory” using a reference counting garbage collector
March 21, 2023
Give a program which gives different results according to whether dynamic
March 21, 2023

Present a right-most derivation for the string (a, ((a, a), (a, a)))

2006 Paper 5 Question 6
Compiler Construction
(a) Consider the grammar
S ::= (L) | a
L ::= L, S | S
(i) Present a right-most derivation for the string (a, ((a, a), (a, a))).
[3 marks]
(ii) Present a left-most derivation for the same string (a, ((a, a), (a, a))).
[3 marks]
(b) Automatic garbage collection is an important technique for the implementation
of many programming languages. Define each of the following variations:
(i) Mark and Sweep; [3 marks]
(ii) Copy Collection; [3 marks]
(iii) Generational Collection. [3 marks]
(c) Write a small program that will produce different values depending on which
kind of variable scoping mechanism is used, static or dynamic. Explain your
answer. [5 marks]