What is the big o running time of the following code

This preview shows page 2 - 5 out of 7 pages.

We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Systems Architecture
The document you are viewing contains questions related to this textbook.
Chapter 3 / Exercise 13
Systems Architecture
Burd
Expert Verified
3. 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.b. If a LinkedList is passed for lst. Explain your answer.
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Systems Architecture
The document you are viewing contains questions related to this textbook.
Chapter 3 / Exercise 13
Systems Architecture
Burd
Expert Verified
4. What is the Big-O running time of the following code fragment?Assume lst1 has N items, and lst2 has N items.public static int Count( List<Integer> lst1, List<Integer> lst2){Iterator<Integer> itr1 = lst1.iterator();int count=0;while ( itr1.hasNext() ){Integer x = itr1.next();Iterator<Integer> itr2 = lst2.iterator();while ( itr2.hasNext() )if ( x.equals( itr2.next()) )count++;}return count;}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.

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture