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

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:00
Create a word problem that involves calculating the volume and surface area of a three-dimensional object. cube: surface area 6 s2 , volume s3
Answers: 3
question
Computers and Technology, 22.06.2019 18:00
Suppose an astronomer discovers a large, spherical-shaped body orbiting the sun. the body is composed mostly of rock, and there are no other bodies sharing its orbit. what is the best way to categorize this body? a. planet b. moon c. comet d. asteroid
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
Which of the following is not an enhancement to the standard wiki to make it more attractive for corporations? encryptionwork spacespermission toolspredictive text
Answers: 2
question
Computers and Technology, 24.06.2019 04:30
Write and test a python program to find and print the largest number in a set of real (floating point) numbers. the program should first read a single positive integer number from the user, which will be how many numbers to read and search through. after reading in all of the numbers, the largest of the numbers input (not considering the count input) should be printed.
Answers: 1
You know the right answer?
The following routine removes the first half of the list passed as a parameter:

public...
Questions
question
Mathematics, 18.10.2019 13:30
question
Social Studies, 18.10.2019 13:30
Questions on the website: 13722360