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 listInverter(List L){

// ADD CODE HERE

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!