1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
djverab [1.8K]
3 years ago
5

For each of the following six program fragments: a) Give an analysis of the running time (Big-Oh will do). b) Implement the code

in the language of your choice, and give the running time for several values of N. c) Compare your analysis with the actual running times. (1) sum
Computers and Technology
1 answer:
lions [1.4K]3 years ago
8 0

Answer:

1) no of computations are :

sum =0 - (1 time )

i=0 ( 1 times)

i<n ( n times )

++sum(n times)

++i (n times)

Total = 3n+2

O(n) is the big O notation

2) no of computations are :

sum =0 - (1 time )

i=0 ( 1 times)

i<n ( n times )

++sum(n^2 times)

++i (n times)

j=0 ( n times)

j<n (n^2 times)

++j (n^2 times)

Total = 3n^2 + 3n+2

O(n^2) is the big O notation as we considered the maximum possible computation

3) no of computations are :

sum =0 - (1 time )

i=0 ( 1 times)

i<n ( n times )

++sum(n^3 times)

++i (n times)

j=0 ( n times)

j<n (n^3 times)

++j (n^3 times)

Total = 3n^3 + 3n+2

O(n^3) is the big O notation as we considered the maximum possible computation

4) no of computations are :

sum =0 - (1 time )

i=0 ( 1 times)

i<n ( n times )

++i (n times)

In the "j" th loop

j=0 ( n times)

j<i (this executes for max of n^2 times when i=n-1)

Similarly ++j (n^2 times when i=n-1)

Hence ++sum(n^2 times)

Total = 3n^2+ 3n+2

O(n^2) is the big O notation as we considered the maximum possible computation

6) no of computations are :

sum =0 - (1 time )

i=0 ( 1 times)

i<n ( n times )

++i (n times)

In the "j" th loop

j=0 ( n times)

j<i*i(this executes for max of n^3 times when i=n-1)

Similarly ++j (n^3 times when i=n-1)

In the "k" th loop

k=0 ( max of n^3 times when j=n^3)

k<j(max of n^4 times when j=n^3)

Similarly ++k(max of n^4 times when j=n^3)

Finally ++sum ( n^4 times when j=n^3)

Total = 3n^4+ 3n^3+3n+2

O(n^4) is the big O notation as we considered the maximum possible computation

5) no of computations are :

sum =0 - (1 time )

i=0 ( 1 times)

i<n ( n times )

++i (n times)

In the "j" th loop

j=0 ( n times)

j<i*i(this executes for max of n^3 times when i=n-1)

Similarly ++j (n^3 times when i=n-1)

In the "k" th loop

k=0 ( max of n^3 times when j=n^3)

k<j(max of n^4 times when j=n^3)

Similarly ++k(max of n^4 times when j=n^3)

Finally ++sum ( n^4 times when j=n^3)

Total = 3n^4+ 3n^3+3n+2

O(n^4) is the big O notation as we considered the maximum possible computation

You might be interested in
Why are modern manufacturing techniques preferred over those historically used by artisans?
zaharov [31]
Manufacturing through machinery allows for below advantages, 

1. Reproducibility - Achieving close to same results is higher.
2. Productivity - Saves time, produce more in quantity and could cost less as materials is saved more.
3. Consistency - Consistent as the method is replicated to a better percentage than manual method.
4. Precision - Use of machines in manufacturing allows for precise measurement of parts.

5 0
3 years ago
The ____ shortcut keys remove character formatting. (points : 2) ctrl 0 (zero) ctrl i ctrl spacebar ctrl u
Bad White [126]
The CTRL+SPACEBAR shortcut keys remove character formatting. 
8 0
3 years ago
Read 2 more answers
_________ analysis is a data mining application that discovers co-occurrence relationships among activities performed by specifi
SSSSS [86.1K]

<u>Affinity analysis </u>is a data mining application that discovers co-occurrence relationships among activities performed by specific individuals or groups, such as market basket analysis.

<h3>What is affinity analysis?</h3>

Affinity Analysis is a type of predictive analysis method that uses data mining to uncover hidden, insightful correlations between various variables based on how frequently they occur between distinct persons or groups in the dataset.

The Product Affinities Analysis sheds light on the items that clients buy in tandem during a shopping trip, such as how they are filling out a broader weekly shopping trip or putting together specific meals.

Therefore, Affinity analysis is a data mining tool that identifies co-occurrence patterns between tasks carried out by particular people or groups, like market basket analysis.

To learn more about affinity analysis, refer to the link:

brainly.com/question/13077215

#SPJ5

5 0
1 year ago
Read 2 more answers
Which best describes a career that would rely on both and employer and the federal government for funding? Electro-Mechanical Te
Dmitrij [34]

Answer:

<u>University Research Professor</u>

Explanation:

A university Professor can identify a research in his/her area of study and prepare a proposal for funding.This could be a research that will impact the nation thus a proposal could be presented to the federal government for funding. Additionally, the Professor can present the same proposal to the university research department to request funding of the project.The University which employed the Professor will now fund that project research and make it public to members of the community about the research that the University is undertaking with the professor as the leader of the research.

8 0
3 years ago
How the (i)?? Help me to slove this
cupoosta [38]

Answer:

#include <fstream>

 ifstream inFile("bookBorrower.txt");

 ofstream outFiles ("overPayment.txt");

Explanation:

fstream has ifstream and ofstream for input and output, respectively.

4 0
2 years ago
Other questions:
  • Retail price data for n = 60 hard disk drives were recently reported in a computer magazine. Three variables were recorded for e
    13·1 answer
  • How does a combustion engine works?
    7·2 answers
  • Bailey wants to add file protection to a document she has created. She wants to restrict users from changing the content she has
    7·2 answers
  • What symbol do you use to choose a feature for your notes on Notion?
    8·1 answer
  • In a client/server architecture, an optional _____ is sometimes used to pass bulk information to the server. a. request line b.
    8·1 answer
  • Type two statements.
    11·1 answer
  • Anyone Free to Talk??????? I'm Bored :(
    6·2 answers
  • If the executives for Office Max LLC, a chain of office supply stores, developed the chain's objectives by asking buyers and sto
    11·1 answer
  • What will happen when you run this program?
    12·2 answers
  • A group of students writes their names and unique student ID numbers on sheets of paper. The sheets are then randomly placed in
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!