hw3 - Assignment#3 Due Dates Wednesday September 21 at...

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

Assignment #3Due Dates: Wednesday, September 21 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. Linked lists and arrays:a. What are some advantages of linked lists versus arrays?b. What are some advantages of arrays versus linked lists?15 points2. What is the Big-O running time of the following code fragment?Assume lst1 has N items, and lst2 is initially empty.public static void add( List<Integer> lst1, List<Integer> lst2){for ( Integer x : lst1 )lst2.add(0, x); // add to front}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();itr.remove();}}a. If an ArrayList is passed for lst. Explain your answer.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture