subject

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

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
What allows you to create a wireless connection among your smart devices
Answers: 2
question
Computers and Technology, 23.06.2019 04:20
4. a1. vince owns a television repair shop that is insured undera commercial package policy. the policy includes thebuilding and personal property coverage form and thecauses-of-loss broad form. the declarations page indicatesthat coverage applies to both the building and the namedinsured's business property. explain whether or not thefollowing losses would be covered under his policy.a. a fire occurs on the premises, and the building isbadly damaged.b. a burglar steals some money and securities from anunlocked safe.c. a business computer is damaged by vandals whobreak into the shop after business hours.d. a tornado touches down near the store. several tel-evision sets of customers in the shop for repair aredamaged in the storm.til
Answers: 2
question
Computers and Technology, 23.06.2019 11:30
Me dangers of social media and the internetexplain what each means: 1) social media and phones have become an addiction.2) outside people have access to you all the time.3) cyberstalking4) cyberbullying5) catphishing6) viruses7) identity theft8) credit card fraud9) hacking10) money schemes
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
What type of slide show is a dynamic and eye-catching way to familiarize potential customers with what your company has to offer? a. ole b. photo album c. brochure d. office clipboard
Answers: 2
You know the right answer?
The RecursionP2 class will have only one class level variables: an ArrayList of Integers that will s...
Questions
question
English, 24.04.2020 01:28
question
Mathematics, 24.04.2020 01:28
Questions on the website: 13722362