Your task in this assignment to add two new types of Mover to Wanderer/Seeker. It is up to you how these Movers should behave — feel free to get as creative as you want with this one. The only constraint is that they must in some way behave differently from either Wanderers or CloseSeekers.
Provided that you have implemented Wanderer/Seeker v2 correctly, this assignment should be relatively short — in fact, if you’ve implemented Wanderer/Seeker v2 right, you can complete this assignment without changing your classes from that assignment (although, depending on the modifications you make, you may have to add additional methods to your mediator object).
Write a method that takes one string as a parameter and returns a boolean indicating whether or not it’s a palindrome. Consult the slides for day 20 for a pseudocode overview.
3.Building a MarkovTable
Create a class named MarkovTable. This class should have a method called readFile that takes a String as a parameter (indicating the name of the file to be opened) and returns a boolean (indicating whether or not the attempt to read a file was successful).
The class should have a private member variable of type HashMap<String, ArrayList<String>>.
Here is how you should populate this HashMap:
- Each unique word in the file should be a key in the HashMap.
- Consider any string of non-whitespace characters as one “word” — so for example “Henceforth” “Henceforth,” and “henceforth” are all different words
- The ArrayList associated with each key should store every word that follows that word.
- When you reach the last word in the file, you should treat the first word in the file as its successor.
For example, if the file consisted of the string:
one fish two fish red fish blue fish
your HashMap for it would hold five items:
fish [two, red, blue, one]
Notice that one is considered to be a successor of fish, because “fish” is both the first and last word of the file.
Your class should also have a toString method that prints the contents of the HashMap in the format above.
Use recursion to implement one of the search algorithms shown in this adorable video https://www.youtube.com/watch?v=FOwCCvHEfY0
For full credit, implement Slowcoach Slade’s algorithm. For 9 points, implement Speedy Spencer’s algorithm. Please do not implement Bozo’s algorithm for this assignment.
Note: your implementation MUST use recursion