subject

The following routine removes the first half of the list passed as a parameter:

public static void removeFirstHalf(List<?> lst)
{
int theSize = lst. size() /2;
for( inti =0; i < theSize; i++ )
lst. remove(0);
}

(a) Why is theSize saved prior to entering the for loop?
(b) What is the running time of removeFirstHalf if lst is an ArrayList?
(c) What is the running time of removeFirstHalf if lst is a LinkedLIst?
(d) Does using an iterator make removeFirstHalf faster for either type of List?

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 19:30, 123iamthe1
You can apply several different worksheet themes from which tab?
Answers: 1
image
Computers and Technology, 23.06.2019 21:40, minnie7760
Draw the resistor’s voltage and current phasors at t=15ms. draw the vectors with their tails at the origin. the orientation of your vectors will be graded. the exact length of your vectors will not be graded.
Answers: 2
image
Computers and Technology, 23.06.2019 22:50, christingle2004
What is an rss reader used for? for creating a user account on a social new site
Answers: 2
image
Computers and Technology, 24.06.2019 06:30, meganwintergirl
Ineed to know the anwser to all these questions
Answers: 2
You know the right answer?
The following routine removes the first half of the list passed as a parameter:

public...

Questions in other subjects:

Konu
English, 10.07.2019 12:00
Konu
Mathematics, 10.07.2019 12:00