Question: Suppose a Java method receives a List and reverses the order of the items it contains by removing each item from the front of the
Suppose a Java method receives a List and reverses the order of the items it contains by removing each item from the front of the list, pushing each item onto a Stack, and after all items are pushed, popping the items from the stack and inserting each item at the end of the list. Assume push and pop are O(1).
What is the expected Big-O running time if:
a. If an ArrayList is passed. Explain your answer.
b. If a LinkedList is passed. Explain your answer.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
