Common Computer Science References
Wiipedia: Recursion (see recursion), in mathematics and computer science, is a method of defining functions in which the function being defined is applied within its own definition.
Create a program using recursion that does one (1) of the following:
In order to make their phone numbers more memorable, service providers like to find numbers that spell out some word (called a mnemonic) appropriate to their business that makes that phone number easier to remember. For example, the phone number for a recorded time-of-day message in some localities is 637-8687 (NERVOUS). Write a recursive function listMnemonics(phoneNumber) that will generate all possible letter combinations that correspond to a given number, represented as a string of digits. This is a recursive backtracking problem, but you are trying to find all the "solutions", not just one. In fact you are trying to find all possible Strings, not just Strings that are actual "words".
For example, if you call
ArrayList<String> result = recursiveObject.listMnemonics("623")
your method shall generate and return an ArrayList containing the following 27 possible letter combinations that correspond to that prefix:
MAD MBD MCD NAD NBD NCD OAD OBD OCD
MAE MBE MCE NAE NBE NCE OAE OBE OCE
MAF MBF MCF NAF NBF NCF OAF OBF OCF
The program reads a single integer from the user. If that integer is less than 1, it prints an error message and stops. Don't ask for a better value. Stop. Otherwise, it prints a pattern of integers as demonstrated in the table below. There is a space before each integer, a newline after each integer greater than 5, and the underlines and boldface are hints to help you see that pattern and are not printed by your program. Your program should work for any positive integer, but because it prints 2n-1 numbers (plus spaces) for input n, do not test it with anything bigger than 15.
n | What is printed out
---------------------------------
1 | 1
2 | 1 2 1
3 | 1 2 1 3 1 2 1
4 | 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
This produces a numeric pattern symmetric about n where each half before and after n is also symmetric around n-1. The newline after printing any integer larger than 5 provides a nice line length and also makes the pattern of the bigger numbers along the right edge reading down. If you get the normal pattern, that will just happen. Don't think about it. Output for an input of 7 is:
1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6
1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7
1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6
1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1
The program reads a single integer from the user. If that integer is less than 1, it prints an error message and stops. The hourglass base case with input 1 displays two lines with one star on each line. Otherwise, it prints a pattern of asterisks or stars (*) as shown below for an input of 4. Note that there are four stars (and spaces) on the first and last lines.
* * * *
* * *
* *
*
*
* *
* * *
* * * *
Consider the number 28. It is not a palindrome. So, I reverse the number and add it to itself (28 + 82 = 110). 110 is not a palindrome. So, I reverse it and add it to itself (110 + 011 = 121). 121 is a palindrome. This means that 28 is a depth 2 palindrome (it took two iterations to make it a palindrome). What is the depth of all two digit numbers? You must use recursion in the solution.
Write a program that will accept how many numbers to generate and then it uses a recursive function to generate that many Catalan Numbers , starting at 1.
Write a program that will accept how many numbers to generate and then it uses a recursive function to generate that many Sylvester's Numbers.
Write a program that will accept how many numbers to generate and then it uses a recursive function to generate that many Tribonacci sequence .
Write a program that will accept how many numbers to generate and then it uses a recursive function to generate that many Tetranacci sequence .
If you are not sure on any part of the problem, just ask me and I will give you additional information
You must do the program in your primary language first (get a 3+). You can get a 4+ by doing the program in your secondary language
Remember to think, Input – Process – Output, when designing your program