Computers and Technology

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( int i = 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 removehalf faster for either type of list?

for part a, what would happen if the for loop was written as?

for (int i = 0 ; i < lst. size()/2 ; i++) {
lst. remove(0) ;
}

how much of the list would be removed? why?

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:00, fluffy374747
The animal classthis class represents a an animal residing at a zoo. it has a weight (in pounds),height (in inches), a name, and a color. the methods in the class include constructors, getters, and a tostring. you will finish the implementation of these methods. referto the code documentation.1.getters: you will need to implement getter methods. these get a value (froma member variable) in the animal class. you will make a getter method toreturn each variable (weight, height, name, color). reference getname if youare having issues.2.tostring: you will need to finish the tostring method. this returns a stringcontaining information about an animal. the output string should be of theformat: ” (name) , a ( color )â’colored animal . ( weight ) pounds , ( height ) inches .\n”the height and weight are formatted to 1 decimal place. recall from lab 1how to format strings neatly using string. see the reference sectionfor more about string. format.
Answers: 2
image
Computers and Technology, 22.06.2019 05:30, donmak3833
Agood flowchart alludes to both the inputs and outputs you will need to receive and give to the user. true or false?
Answers: 3
image
Computers and Technology, 22.06.2019 06:00, kamilahmcneil3969
What are the most likely causes of conflict at the meeting? check all that apply.
Answers: 1
image
Computers and Technology, 22.06.2019 14:00, michelle7511
Which database model is best used for data warehouse and data mining
Answers: 3
Do you know the correct answer?
The following routine removes the first half of the list passed as a parameter:
public static...

Questions in other subjects: