What is the big o running time of the following code

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

We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Java Programming
The document you are viewing contains questions related to this textbook.
Chapter 9 / Exercise 18
Java Programming
Farrell
Expert Verified
3.  What is the Big-O running time of the following code fragment?    Assume lst1 has N items, and lst2 has M 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.
4.  What is the Big-O running time of the following code fragment?    Assume lst1 has N items, and lst2 has M items.
We have textbook solutions for you!
The document you are viewing contains questions related to this textbook.
Java Programming
The document you are viewing contains questions related to this textbook.
Chapter 9 / Exercise 18
Java Programming
Farrell
Expert Verified

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture