title: Algorithm for a Context Free Grammar
body: <p>I'm trying to design an algorithm that takes as input a CFG G, and a terminal symbol a, and outputs yes if S (the starting rule of G) can generate a sentential form that starts with a. i.e., if there is a string α in (T U N)* such that S =>* aα , else it outputs no. For example, if the grammar is S - > [S] | SS | ε, and if a = ], the answer is no. I'm not looking for code, I'm just trying to understand how I should approach this topic in pseudo code.</p>