# Assignment3.docx - Assignment#3 Due Dates Saturday June 2...

• Homework Help
• 3

This preview shows page 1 - 3 out of 3 pages.

Assignment #3Due Dates: Saturday, June 2 at 11:59pm Submit: eLearningLate Policy: -10 points per hour lateInstructions: This is an individual assignment. Answers should be your own work.Chapter 310 points1. Why is inserting into an array considered slow compared to insertinginto a linked list?15 points2. What is the Big-O running time of the following code fragment?Assume lst1 has N items, and lst2 and lst3 are initially empty.public static void add( List<Integer> lst1, List<Integer> lst2, List<Integer> lst3){for ( Integer x : lst1 ){lst2.add(0, x); // add to frontlst3.add(x); // add to end}}a. If an ArrayList is passed for lst1 and lst2. Explain your answer.b. If a LinkedList is passed for lst1 and lst2. Explain your answer.15 points3. What is the Big-O running time of the following code fragment?public static void erase( List<Integer> lst ){Iterator<Integer> itr = lst.iterator();while ( itr.hasNext() ){Integer x = itr.next();if (x % 2 == 0)itr.remove();}}a. If an ArrayList is passed for lst1 and lst2. Explain your answer.
b.
• • • 