In this assignment you are to use ArrayList of ArrayLists and Recursion. Although you are solving the hailstone problem, you are being asked to report the longest hailstone sequence for all sequences from 1 to n where n is input by the user.
The
hailstone sequence
is an algorithm that starts with a positive integer and then, through a series
of changes ends up with (hopefully) a never-ending sequence of 4-2-1.
For any n > 1,
The ArrayList parameter will have a record of the complete sequence of numbers generated. For example, if called with 5 the list would contain [ 5, 16, 8, 4, 2, 1].
The Driver will begin by asking the user to enter a positive integer.
(This is just an integer, we are using long integers above
because we don’t know how big they might get.)
It will then enter a counting loop from 1 to the number entered.
For each "i", it will create a HailStone object,
passing it both "i" and an ArrayList to store the values.
Since hailStone has a separate method to do the actual calculationsr,
you can call it from the HailStone constructor or your Driver (your choice).
At the end of your counting loop, you will have a an arrayList of
arrayLists.
Determine which of the sequences is longest. Note this is done
after all the data is stored, not while the data set is being created.
Output
Provide explanatory output such as this:
To generate this output, you MUST use a
a recursive display method to repeatedly delete the first element
in the sequence and show it on the console, until the list is empty.
dd
The latter is pretty simple and may be implemented as a static function that is called from main().