What is big-o running time of subsequent code fragment

Assignment Help Computer Engineering
Reference no: EM13698084

Question 1:  What is the Big-O running time of the subsequent 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.  Clarify your answer.

   b.  If a LinkedList is passed for lst1 and lst2.  Clarify your answer.

Question 2:  What is the Big-O running time of the subsequent code fragment?

    Assume lst has N items.

     public static int calc( List<Integer> lst )

      {

         int count = 0;

         int N = lst.size();

 

         for ( int i=0; i<N; i++)

         {

            if (lst.get(i) > 0)

               sum += lst.get(i);

            else

               sum += lst.get(i) * lst.get(i);

         }

         return sum;

      }

   a.  If an ArrayList is passed.  Describe your answer.

   b.  If a LinkedList is passed.  Describe your answer.

Reference no: EM13698084

Questions Cloud

Create a console-based application named multiplication : Create a console-based application named Multiplication whose main() method asks the user to input and then calls a method named MultiplicationTable(), which displays the results of multiplying the integers by each of the number 2 through 10
Which of the sollowing is an accurate statement : Which of the subsequent is an accurate statement - When the LOWER function is used in a SELECT clause, it will automatically store the data in lower-case letters in the database table.
How do you initiate an array with a proper amount of values : How do you initiate an array with a proper amount of values?
What are the ethical implications of this : Many of the studies researching cell phones safety have been funded by the cell phone industry - What are the ethical implications of this?
What is big-o running time of subsequent code fragment : What is the Big-O running time of the subsequent code fragment - If an ArrayList is passed.  Describe your answer.
What is big-o running time of following code fragment : What is the Big-O running time of the given code fragment and If an ArrayList is passed for lst. Describe your answer.
What is the big-o running time of the given code : What is the Big-O running time of the subsequent code fragment and If an ArrayList is passed for lst1 and lst2.  Describe your answer.
Provide a laymans explanation of uml : Describe one scenario in which it would be advantageous for you to use a definite loop as opposed to an indefinite loop when developing a program. Provide a rationale for your response.
Design a java application using the list data structure : You are to design a Java application using the list data structure to manage your contact information. Each contact may have the subsequent data:

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd