2. For each of the following three program fragments, give an analysis of the running time....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
2. For each of the following three program fragments, give an analysis of the running time. First, give the total number of times of each statement being executed. Then give the summed/total time in Big- O notation using function with the least order of magnitude. Basically don't say the complexity is O(N9) if it is also O(N2). (21 pts) (a) Sum = 0; for(i= 1; i N; i++) Sum Sum + i; (b) Sum= 0; for(i=1;i< N;i++) for(j= 1; j≤ N²; j++) for(k = 1; k< N; k++) Sum Sum + 1; (c) Sum = 0; for (i = 1; i ≤ N; i++) for(j= 1; ji; j++) Sum Sum + 1; (d) x = 100; y = 0; for(i= 1; i ≤ N; i = 2 * i) x = x + i; for(j= 1; j< N; j++) if(x > y/j) y = y + i/j; else y = y - 1; 2 2. For each of the following three program fragments, give an analysis of the running time. First, give the total number of times of each statement being executed. Then give the summed/total time in Big- O notation using function with the least order of magnitude. Basically don't say the complexity is O(N9) if it is also O(N2). (21 pts) (a) Sum = 0; for(i= 1; i N; i++) Sum Sum + i; (b) Sum= 0; for(i=1;i< N;i++) for(j= 1; j≤ N²; j++) for(k = 1; k< N; k++) Sum Sum + 1; (c) Sum = 0; for (i = 1; i ≤ N; i++) for(j= 1; ji; j++) Sum Sum + 1; (d) x = 100; y = 0; for(i= 1; i ≤ N; i = 2 * i) x = x + i; for(j= 1; j< N; j++) if(x > y/j) y = y + i/j; else y = y - 1; 2
Expert Answer:
Answer rating: 100% (QA)
Answer A Lets analyze the running time for each of the given program fragments Sum 0 fori 1 i N i Su... View the full answer
Related Book For
Research Methods For Business Students
ISBN: 9781292208787
8th Edition
Authors: Mark Saunders, Philip Lewis, Adrian Thornhill
Posted Date:
Students also viewed these programming questions
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
THE SHOPPES AT RIVERSIDE Fonda L. Carter, Columbus State University Kirk Heriot, Columbus State University CASE DESCRIPTION This case asks the students to recommend a decision to a group of...
-
Build Right Supply, Co., shows the following financial statement data for 2014, 2015, and 2016. Prior to issuing the 2016 statements, auditors found the ending inventory for 2014 was understated by...
-
Potvin Company produces mathematical and financial calculators and operates at capacity. Data related to the two products are presented here: Total manufacturing overhead costs are as follows....
-
Bright Red Cannery makes three products from a single joint process. For 2013, the cannery processed all three products beyond split-off. The following data were generated for the year: Analysis of...
-
Explain events and their importance in dynamic modeling.
-
As she headed toward her boss's office, Emily Hamilton, chief operating officer for the Aerocomp Corporation-a computer services firm that specialized in airborne support-wished she could remember...
-
Jordan has student loan debt and is worried that it will reduce that amount that can be borrowed for a home. While the percentage of income for a house payment is not a problem, but there is also a...
-
Alfonso Inc. acquired 100 percent of the voting shares of BelAire Company on January 1, 2020. In exchange, Alfonso paid $198,000 in cash and issued 100,000 shares of its own $1 par value common...
-
You are tasked with evaluating if a company is fairly priced. The fund is actively managed and seeks to outperform the S&P 500. Over the past 10 years, the fund returned 10.25% per year and had a...
-
Identify at least two ways to find experts you can interview on a topic.
-
Why is an executive summary important in a longer proposal?
-
Some analysts argue that the prevalence of social networking and social media excludes older workers and older customers who are not comfortable with digital communication. If this is true, what can...
-
As you learned in the Culture feature, in China, proposals initiate negotiations. In Italy, proposals finalize negotiations. What are the implications of these differences for how you would approach...
-
What is the difference between an internal proposal and an external proposal? Which is more likely to be formal, and which is more likely to be informal?
-
Roman's Inc Limited provided the following income (loss) information for the first five years of its operations. Roman's does not have any GAAP (Book) Tax differences so that reported income per...
-
During registration at Tech every quarter, students in the Department of Management must have their courses approved by the departmental advisor. It takes the advisor an average of 4 minutes...
-
What are the advantages of using semi-structured and in-depth interviews?
-
You are working in an organisation that has branches throughout the country. The managing director is mindful of the fact that managers of the branches need to talk over common problems on a regular...
-
a. How many variables will be generated from the following request? b. How would you go about devising a coding scheme for these variables from a survey of 500 cinema goers? Please tell me up to five...
-
What are the four main consumer rights?
-
What is the role of the Securities and Exchange Commission?
-
In what ways do companies demonstrate their social responsibility?
Study smarter with the SolutionInn App