Your answer for the first question is right.
The second question for a recursive function is pretty easy, assuming it only is supposed to handle odd length arrays of the language that grammar implements. Seems to be a simple recursive function that checks through a heirarchy of ifs.
Pseudocode:
palindrome (s[], first, last)
if s[first] == s[last] and s[first] == 'a' or 'b'
if first == last
This string is in the language
else
So far this string is in the language
palindrome (s[], first+1, last-1)
else
This string is not in the language
I r teh l33t w/ Recursion
hinde
Junior Poster in Training
60 posts since Jul 2005
Reputation Points: 10
Solved Threads: 4
Skill Endorsements: 0