Ask Question
18 July, 12:54

Why is thesize saved prior to entering the for loop? 2. what is the running time of removefirsthalf if lst is an arraylist? 3. what is the running time of removefirsthalf if lst is a linkedlist?

+4
Answers (1)
  1. 18 July, 13:14
    0
    After entering the loop, it should use the correct list size and the loop will be affected if the remove call changes the size of the list. If lst is an Arraylist the running time of removefirsthalf is O (n^2). So when the beginning is removed the next element will move forward. If lst is a LinkedList which is a dynamic structure the running is O (n) for removefirsthalf
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Why is thesize saved prior to entering the for loop? 2. what is the running time of removefirsthalf if lst is an arraylist? 3. what is the ...” in 📗 Physics if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers