Question

When counting the number of arithmetic operations in evaluating an expression, we often make the simplifying...

When counting the number of arithmetic operations in evaluating an expression, we often make the simplifying assumption that each operation has the same cost. For example, consider the following statement from the Merge-Sort algorithm for dividing the problem into two equal problems. q = ⌊(? + ?)/2⌋ we would say that the evaluation requires a total of 3 arithmetic operations (+, / and “floor”). That is, the time cost is 3. If that statement was embedded in a loop that executed 5 times, then we would say that the statement has a time cost of 5*3 = 15 arithmetic operations. Now consider this equation that was used in calculating the execution time for insertion sort. ∑ ? ? ?=2 = ?(?+1) 2 − 1 What is the difference in the time cost T(n) in terms of the number of arithmetic operations required to compute this formula depending on whether the algorithm is expressed based on the summation approach on the left-hand side of the equation or based on the closed formula approach on the right hand side of the equation as a function of the problem size n? You should express your analysis using the theta (Θ) notation.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

For taking sum of j over j = 2 to n,

1. Using the right side formula, we get 4 operations, namely

n + 1,

n X (n + 1),

n X (n + 1) / 2,

and n * (n + 1) /2 - 1

Thus this equation is Theta(1) as we have constant number of operations for any n.

2. Using the loop at left side, we are calculating sum + j at every value from 2 to n,

Therefore it takes n - 1 steps to calculate.

Therefore the method is Theta(n).

The difference between the number of steps between the 2 methods is = (n - 1) - 4 = n - 5

This means that left side method takes n - 5 steps more than right side.

Hope this helps.

Please rate the answer if you like it.

Do leave a comment.Any suggestion/query is much appreciated.

Add a comment
Know the answer?
Add Answer to:
When counting the number of arithmetic operations in evaluating an expression, we often make the simplifying...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 4 Problem 4 -Extra Credit Given an array A, we say that elements A and Al...

    4 Problem 4 -Extra Credit Given an array A, we say that elements A and Al are swapped if J >「 but Alj]< A[i]. For example, if A - [8,5,9,7], then there are a total of3 swapped pairs, namely 8 and 5; 8 and 7; and 9 and 7 Describe a recursive algorithm that given an array A, determines the number of swapped pairs in the array in O(n log(n)) time. To analyze the algorithm, you must state the recurrence...

  • What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that...

    What is the role of polymorphism? Question options: Polymorphism allows a programmer to manipulate objects that share a set of tasks, even though the tasks are executed in different ways. Polymorphism allows a programmer to use a subclass object in place of a superclass object. Polymorphism allows a subclass to override a superclass method by providing a completely new implementation. Polymorphism allows a subclass to extend a superclass method by performing the superclass task plus some additional work. Assume that...

  • Mary Benninger had sought out her old friend, Tom Chu, to discuss her employment situation. Mary...

    Mary Benninger had sought out her old friend, Tom Chu, to discuss her employment situation. Mary and Tom had both graduated in 1985 from Mackenzie King University, and then studied together to attain their CMA designations in 1988. Soon thereafter, Tom was promoted quickly within his division of a large multi-national auto supply company, and now held the position of vice-president/controller. Mary, on the other hand, had temporarily removed herself from full-time employment in 1990 to raise her young daughter....

  • Playgrounds and Performance: Results Management at KaBOOM! (A) We do this work because we want to...

    Playgrounds and Performance: Results Management at KaBOOM! (A) We do this work because we want to make a difference in the world; how can we go further faster? - Darell Hammond, CEO and co-founder, KaBOOM! Darell Hammond stepped onto the elementary school playground and took a long, slow look around. It was 8 a.m. on an unusually warm fall day in 2002 and the playground was deserted, but Hammond knew the children would start arriving soon to admire their new...

  • Hi, Kindly assist with my project management assignment below using the attached case study Question 1 Update the project charter for the remainder of the project in response to Adams’ memo (lines 241...

    Hi, Kindly assist with my project management assignment below using the attached case study Question 1 Update the project charter for the remainder of the project in response to Adams’ memo (lines 241 through 246). Question 2 Prepare a plan for the remainder of the project in response to Adams’ memo (lines 241 through 246). Your answers to the above will be assessed in terms of the level of communication displayed, the insights and inferences drawn, and your ability to...

  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

  • Here is the text book information, trend needs to be return on investment Calculate one financial...

    Here is the text book information, trend needs to be return on investment Calculate one financial statement ratio trend within your industry that warrants improvement efforts. Make up your own. Return on Investment LO 2 Explain the importance and show the calculation of return on investment. Imagine that you are presented with two investment alternatives. Each investment will be made for one year, and each investment is equally risky. At the end of the year you will get your original...

  • Ch 1 1. Given the following dat Dec 31 Year 2 Dec 31 Year 1 Total...

    Ch 1 1. Given the following dat Dec 31 Year 2 Dec 31 Year 1 Total liabilities S128,250 $120,000 Total stockholders oquity 95.000 80.000 compute the ratio of liabilities to stockholders' equity for each year Round to two decimal places 1.50 and 107, 11.35 and 1.50 respectively respectively 1.07 and 1.19. 1.1.19 and 1.35 respectively respectively The liabilities and stockholder's equity of a company are $132,000 and $244.000, respectively. Assets should equal SS188.00 $132.00 p $376,00 12.000 A financial statement...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

  • Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around...

    Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT