Question: In this project, you will write Java programs to implement recursive definitions of the following languages. Your main() function should read in one command-line value
In this project, you will write Java programs to implement recursive definitions of the following languages. Your main() function should read in one command-line value and then indicate with an output of true or false whether or not that value is in the language.
Output should be formatted as shown in the following sample session:
Run
>java TestDivisibleBy7 28
X = 28 Member? true
Turn in source code for all programs, along with the requested output.
1. Language DivisibleBy7 is defined recursively as:
(1) Integer 7 is in DivisibleBy7.
(2) If x is in DivisibleBy7, then so is x + 7.
Encode DivisibleBy7 as a Boolean recursive function. Test your function for input values:
382, 749, 2977, 9989, 52878.
2. Language PowersOf2 is defined recursively as:
(1) Integer 1 is in PowersOf2.
(2) If x is in PowersOf2, then so is 2x.
Encode PowersOf2 as a Boolean recursive function. Test your function for input values:
128, 257, 1023, 8192, 65536.
3. Language SumXY is defined recursively as:
(1) Integers 17 and 43 are in SumXY.
(2) If x and y are in SumXY, then so is x + y.
Encode SumXY as a Boolean recursive function. Test your function for input values:
12, 51, 137, 364, 589.
4. For alphabet {a,b}, the language OddPalindrome is defined recursively as:
(1) Words a and b are in OddPalindrome.
(2) If w is a word in OddPalindrome, then so are awa and bwb (concatenation).
Encode OddPalindrome as a Boolean recursive function. Test your function with input values: abaaba, bbaabbb, abababa, aabcbaa, baabbbaab.
5. For alphabet {a,b}, the language ContainsABA is defined recursively as:
(1) Word aba is in ContainsABA.
(2) If w is a word in ContainsABA, then so are aw, bw, wa, and wb.
Encode ContainsABA as a Boolean recursive function. Test your function with input values:
abaaba, bbaabbb, abbababa, aabbbbaa, baababcab.
6. For alphabet {a,b,+}, the language ABPlus is defined recursively as:
(1) Words a and b are in ABPlus.
(2) If v and w are words in ABPlus, then so are vw and v+w.
Encode ABPlus as a Boolean recursive function. Test your function with input values:
aba+ba, b+ba+bb, ab++ba+a, +aab+bba, b+abb+ab+, a+bbc+bba.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
