Computers and Technology

The RecursionP2 class will have only one class level variables: an ArrayList of Integers that will store a data set on which you will be performing different operations using recursive function. All these functions can also be done using iteration, however, you are restricted to only use recursion for full credit. Your program might be randomly checked and any non-recursive approach will be marked down.

The following non-static public methods have to be declared in your class:

Constructor (1-arg)

The constructor will accept in an 1-D array of type int of unknown length and add every element to the class level ArrayList.
reverseList(ArrayList)

The method will accept in an ArrayList of type Integer and return a new ArrayList of type Integer that has all the elements in the reverse order. You are only allowed to use recursion for this method.
reverseList()

The method will use the class level ArrayList and return a new ArrayList of type Integer that has all the elements in the reverse order. You are only allowed to use recursion for this method.
Hint: This method is a special case of reverseList(ArrayList) and you are allowed to use that method if it helps.
toOddList(ArrayList )

The method will use the class level ArrayList as a parameter and return a new ArrayList of type Integer that contains all the odd indexed numbered elements of the class level ArrayList. You are only allowed to use recursion for this method.
toOddList()

The method will accept in an ArrayList of type Integer and return a new ArrayList of type Integer that contains all the odd indexed numbered elements of the class level ArrayList.
Hint: This method is a special case of toOddList(ArrayList) and you are allowed to use that method if it helps.
toEvenRevList(ArrayList )

The method will accept in an ArrayList of type Integer as a parameter and return a new ArrayList of type Integer that contains all the even indexed numbered elements of the class level ArrayList in reverse order. You are only allowed to use recursion for this method.
You can use the reverseList() method as a helper method.
toEvenRevList()

The method will use the class level ArrayList and return a new ArrayList of type Integer that contains all the even indexed numbered elements of the class level ArrayList in reverse order. You are only allowed to use recursion for this method.
Hint: You can use toEvenRevList(ArrayList) or reverseList(ArrayList) as a helper method.
retPenultimate(ArrayList )

The method will accept in an ArrayList of type Integer and return an int which is the last element of the ArrayList. If the list is empty/null, it should return -1. As usual, you are only allowed to use recursion for this method and the use of reverseList() is prohibited.
getList()

The method would return the class level ArrayList. The return type is ArrayList.
Example

Original: [2, 4, 6, 8, 10]
reverseList(): [10, 8, 6, 4, 2]
toOddList(): [4, 8]
toEvenRevList(): [10, 6, 2]
retPenultimate(): 10

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 20:50, rrrrainy
What are the advantages of google cloud ?
Answers: 2
image
Computers and Technology, 22.06.2019 07:20, Hcalhoun21
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display “enter a value to be cubed.” input value; set cube = value ^ 3 display value, “ cubed is “, cube end while
Answers: 2
image
Computers and Technology, 22.06.2019 10:00, banna01man
You need a reliable network for about twenty-five computers that will be distributed across a large building. it is important that the network be relatively cheap. which topology should you use?
Answers: 1
image
Computers and Technology, 23.06.2019 18:40, brooklyn4932
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
Do you know the correct answer?
The RecursionP2 class will have only one class level variables: an ArrayList of Integers that will s...

Questions in other subjects:

Konu
World Languages, 30.06.2019 16:30
Konu
Mathematics, 30.06.2019 16:30