Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following routine removes the first half of the list passed as a parameter: [10 Points] public static void removeFirstHalf(List lst) { int theSize =
-
The following routine removes the first half of the list passed as a parameter:
The following routine removes the first half of the list passed as a parameter:
[10 Points]
public static void removeFirstHalf(List> lst)
{
int theSize = lst.size() /2
for( inti =0; i < theSize; i++ )
lst.remove(0);
}
-
Why is theSize saved prior to entering the for loop?
-
What is the running time of removeFirstHalf if lst is an ArrayList?
-
What is the running time of removeFirstHalf if lst is a LinkedLIst?
-
Does using an iterator make removeFirstHalf faster for either type of List ?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started