Easy, Quick recursion programs
$30-40 USD
Maksettu toimituksen yhteydessä
1. Write a java class named **my_WordReverse** using recursion. It takes a sentence and returns the sentence in reverse order. For example, given “welcome to recursion world?? as input, the program should print out “world recursion to welcome??. Note that space is the only separator.
2. Write a recursive function **my_findAncestorsDescendants** to find all the ancestors and descendants of X.
**Input:** “Relationship pairs?? and element X. Each pair is of the form, (father, child)
**Output:** all ancestors and descendants of X
For example: we have the following pairs (the sequence of the pairs is random):
(Nick, John) (Jack, Nilson) (Tom, Mike) (John, Jack) (Jack, David)
If we use **my_findAncestorsDescendants**() to find the ancestors of Jack, <John, Nick>, and descendants of Jack, <David>, should be returned.
**Instructions**
1. Ther programs should run like:
Problem 1:
Enter string:
welcome to recursion world
Reverse string:
world recursion to welcome
Problem 2: (In testing the program, I can input any number of relationship pairs).
Enter the relationship pairs:
(Jack, Nilson) (Jack, David), (Peter, John) (David, Bert) (Tom, Mike) (John, Jack)
Whose ancestors and descendants do you want to find?
Jack
Result: Jack’s ancestors are <Peter, John>
Jack’s descendants are <Nilson, David, Bert>
Note that: the sequences of the returned ancestors and descendants are not important.
## Deliverables
**What I need**: You have to write two java files, one is named **[url removed, login to view]**, and the other is named **my_findAncestorsDescendants****.java**. You should write main function within each java file. So that after compiling them, I can run it directly.
Please comment the code.
Also, you MUST use recursion for both problems. I will not accept any program that does not use recursion even if the program for the question works perfectly fine.
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition.
## Platform
Has to be written in java
Projektin tunnus: #3398393