Question: Write a non-member method named listInverter() that receives as parameter a list L. The method changes List L by inverting the list in time O(n),
Write a non-member method named listInverter() that receives as parameter a list L.
The method changes List L by inverting the list in time O(n), where n = L.size().
Solutions that are not O(n) will get at most 50% of the score obtained from the tester.
For example, if L = {Bob, Apu, Ned, Joe}, then a call to listInverter(L) converts L into L = {Joe, Ned, Apu, Bob}. Notice that L is changed after the function call.
Hint: Think about using another auxiliary list to help you out!
public static List
// ADD CODE HERE
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
