The algorithm presented in Figure 4.8 retains no information between invocations of FIRST. As a result, the solution for a given nonterminal might be computed multiple times.
(a) Modify the algorithm so it remembers and references valid previous computations of First(A), A N
(b) Frequently an algorithm needs First sets computed for all X N. Devise an algorithm that efficiently computes First sets for all nonterminals in a grammar. Analyze the efficiency of your algorithm.
(c) Repeat this exercise for the Follow sets.