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, 24.06.2019 02:10, ttangelique
Which sentences describe the things you need to ensure while creating a sketch and a drawing? while an artistic or creative drawing is a creative expression, a technical drawing is an informative expression. you need to create accurate and neat drawings to convey accurate information. a technical drawing clearly conveys its meaning or information, and does not leave room for interpretation maintain a good speed while creating drawings
Answers: 1
image
Computers and Technology, 24.06.2019 20:10, austinwst3
Approximately what portion of global employers tends to use social media websites to hire new employees?
Answers: 1
image
Computers and Technology, 25.06.2019 05:10, ethanmel21
Assume that two parallel arrays have been declared and initialized: healthoption an array of type char that contains letter codes for different healthcare options and annual cost an array of type int. the i-th element of annual cost indicates the annual cost of the i-th element of healthoption. in addition, there is an char variable, best2.write the code necessary to assign to best2 the health option with the lower annual cost, considering only the first two healthcare options. thus, if the values of healthoption are 'b', 'q', 'w', 'z' and the values of annualcost are 8430, 9400, 7050, 6400 your code would assign 'b' to best2 because 8430 is less than 9400 and is associated with 'b' in the parallel array. (we ignore 'w' and 'z' because we are considering only the first two options.)
Answers: 1
image
Computers and Technology, 25.06.2019 08:40, lflugo6oyn4sp
Which of the following statements is incorrect in relation to processes: while, strictly speaking, at any instant of time, the cpu is running only one process, in the course of 1 second, it may work on several of them, giving the illusion of parallelism a process is just an instance of an executing program, including the current values of the program counter, registers, and variables processes can be created when an operating system is booted, created by the user, or a running process can create children processes there is a master process, which when started can last forever, and is not killable
Answers: 3
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: