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( 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?

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:30
Jason needs to learn a new web tool. he went through his books to understand more about it. now he wants hands-on experience with using that tool. what would him? jason can use websites where workspace is provided to test the results of your code.
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
*! 20 points! *jeff wants to create a website with interactive and dynamic content. which programming language will he use? a. dhtml b. html c. css d. javascript
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Visualizing a game of “tag” to remember the meaning of contagious
Answers: 3
You know the right answer?
The following routine removes the first half of the list passed as a parameter:
public static...
Questions
question
Health, 25.08.2019 20:50
question
Advanced Placement (AP), 25.08.2019 20:50
Questions on the website: 13722367