3 ms·
Hmmm... represent the parameters as nodes in a directed graph. For each of m recursive call sites, process each of n parameters and add edges from formal parame
by belovedeagle 11y ago
Hmmm... represent the parameters as nodes in a directed graph. For each of m recursive call sites, process each of n parameters and add edges from formal parameter name to passed argument (i.e., if we have signature foo(a,b,c) and recursive call foo(c,b,c), add edge a->c; self-edges are unimportant). This step is O(mn). Then, assuming we already know what parameters are used outside of function calls, flood-fill the graph from those nodes; this is O(n). O(mn+n)=O(m*n).
- vikiomega9 11y ago> "Then, assuming we already know what parameters are used outside of function calls" This is something that needs to be done, I guess my confusion was that you already have this information and that should be sufficient to finding the unused parametres.