COSC4307 PROGRAM-1 EXPRESSION COUNTING Due: Tuesday, 9/15/2009 CONSIDER THE FOLLOWING CFG GRAMMAR GENERATING ARITHMETIC EXPRESSIONS involving 1. four operators: + - * / 2. only one operand: a 3. parentheses: ( ) E -> E + T E -> E - T E -> T T -> T * F T -> T / F T -> F F -> ( E ) F -> a Write a well-structured program that computes and prints out the total count of all distinct expressions of length N where N=3,4,5,6,7,9, respectively. FOR EXAMPLE, IF N=3, THERE ARE 5 DIFFERENT EXPRESSIONS. AND THEY ARE: a+a a-a a*a a/a (a) Suggestions: Use the following recursive functions: int E (int N) { int count; count=0; for (int k=1, k<=N-2, k+=2) count = count + E(k)*T(N-k-1); return T(N)+2*count; } // Similarly for "int T(int N)"// int F (int N) { if (N==1) return 1; if (N>=3) return E(N-2); else return 0; }