Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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 lst1, List lst2)

   {

      Iterator itr1 = lst1.iterator();

      int count=0;

      while ( itr1.hasNext() )

      {

         Integer x = itr1.next();

         Iterator 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 lst )

      {

         int count = 0;

         int N = lst.size();

 

         for ( int i=0; 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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91237521

Have any Question?


Related Questions in Computer Engineering

Suppose i am designing a personnel database for a

Suppose I am designing a personnel database for a university. The university has three types of personnel: students, staff, and faculty. Here are the characteristics of the three groups: -All three groups have a name and ...

Suppose pointers are 4 bytes long and keys are 12 bytes

Suppose pointers are 4 bytes long, and keys are 12 bytes long. How many keys and pointers will a block of 16,384 bytes have?

At a certain temp the kp for the decomposition of h2s is

At a certain temp, the Kp for the decomposition of H2S is .883. H2S (g) ----> H2(g) + S (g) Initially, only H2S is present at a pressure of  .181 atm  in a closed container. What is the total pressure in the container at ...

Why are some nations economically strong and others

Why are some nations economically strong and others economically weak?

Question 1 identify the three main types of computer

Question: 1. Identify the three main types of computer software that were discussed in your unit lesson. Within the three main categories, give examples of each and a brief explanation of each. Each explanation/descripti ...

Can someone explain to me how stooge works in the most

Can someone explain to me how Stooge works in the most simplified way. Because am having a hard time understanding it. There was an example on youtube that goes like this: if you are given a small array of numbers that w ...

Question overview of information security and risk

Question: Overview of Information Security and Risk Management (Due Oct 24) Does your company (or school) have a current disaster recovery plan? What are some of the activities involved in it? Do you feel confident that ...

What are security planning principles what is policy-based

What are Security Planning Principles? What is policy-based security? (Hint for both: pure definition is not good enough. Answers need to be illustrated in the context of an example or scenario).

Decision support systems dss what sorts of dss tools do you

Decision support systems (DSS). What sorts of DSS tools do you use at your work - e.g., what-if analysis, sensitivity analysis, scenario analysis, goal-seeking analysis, optimization analysis, etc.? Even if you don't use ...

After reading the case presented in the module write a

After reading the case presented in the module, write a short response to the following discussion questions and ethical decision making scenario. Discussion Questions What project management tasks should Kelvin perform ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As