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
URGENT!!!
Alona [7]

False is your answer

5 0
3 years ago
Read 2 more answers
Write a program that outputs "Hello World!".
tekilochka [14]
Print(“Hello World!”)

I hope this helps :) I’m sry is this what you wanted or were you looking for something else because I’m willing to help either way.
4 0
2 years ago
A user logs on to her account and is able to makes changes to her desktop, like adding a background and screen saver. However, w
enot [183]

Answer: The user had a mandatory profile.

Explanation:

A user profile is considered mandatory and such profile is known as pre-configured roaming user profile that only administrators can use to make precise settings for clients. In this type of profile, one can adjust his or her desktop settings, the adjustment are temporarily stored after logging off from the profile.

8 0
3 years ago
There are many programming languages in robotics. Each language has its own advantage. According to your opinion, which language
Dmitriy789 [7]

Answer:

you can use the notepad and *if your on windows 10* you can HTML and create websites and you can also use binary code*but that will take .2 BILLION years.

Explanation:

my point is just ask your teacher

3 0
3 years ago
The primary objective of database design is what?
professor190 [17]

Answer:

D)

Explanation:

4 0
3 years ago
Other questions:
  • An IT technician has manually configured an IP address on a laptop for a new employee. Each time the employee tries to connect t
    8·1 answer
  • If you want to conserve ink or toner, you can instruct PowerPoint to print ____ documents.
    10·1 answer
  • An important safety precaution you should take before starting any electrical servicing job is to make sure that your
    15·2 answers
  • What protocol suite below is the most commonly used protocol for local area network (lan) communication?
    8·1 answer
  • . Two or more functions may have the same name, as long as their _________ are different.
    9·1 answer
  • What is the name for the type of flash memory that is used by mobile devices to store their apps and data?
    6·1 answer
  • A noisy signal has been uploaded to D2L in the files fft_signal.mat and fft_signal.txt.Write a program to estimate the power spe
    10·1 answer
  • Similarities between drawing toolbar and editing toolbar​
    12·2 answers
  • Drag each statement to the correct location.
    10·1 answer
  • Which tab is the "page break" command found on? (there are two!) *
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!