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

  How big is a single interval in volts

Receivers have no choice but to decode the the binary sample value at the center of the interval. So, what would the received voltage of the sample be?

  Estimating the performance of processor

Without any hardware support, context switch time is not zero. This states that the actual performance will not be as good as the ideal above.

  Create a wbs and enter the tasks in project

Enter realistic durations for each task. Assume you have only four months to complete the project. Take a screen shot of the resulting Gantt chart and paste this into the Word for Windows file.

  Exemplify the predisposition towards web development

PHP and ASP are both well suited for web development. What are some of the features and capabilities that exemplify this predisposition towards web development? Are there any implementations for running client-side PHP.

  Developing the algorithm and analyzing its running time

Katt wishes you to develop an algorithm that, provided a string X, computer efficiently how many ways X can be broken up into the sequence of words.

  Implementing the python atm program

Write down a simple Python ATM program. Ask user to enter their account number, and then print their beginning balance. Then ask them if they wish to make a deposit or a withdrawal.

  Use the .net framework class linrary constant

When user clicks a button to perform the calculation, the button's event procedure should first determine that a selection for the calculation type was made. Next, event procedure should ensure that non-zero, positive values have been entered only..

  Question 1a what is the main advantage of using master

question 1a what is the main advantage of using master pages?b explain the purpose and advantage of using styles?c name

  Manufacturers are continuously releasing firm-ware upgrades

manufacturers are continuously releasing firmware upgrades for their products. if you were the manager of a wlan how

  Questionwrite down an account class which represents a

questionwrite down an account class which represents a saint anselm college bank account with basic service such as

  Implementing c++ program that simulates a submarine

Design and implement the C++ program which simulates a submarine. If sub tries to leave area or it wanders into the shallow area, the simulation should end. Initialize array to -1. The user should be able to move the sub up, left, right and down.

  A 32-bit word on the little-endian computer has decimal

a 32-bit word on the little-endian computer has decimal value of 261. if it is transmitted to the big-endian computer

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