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
zhuklara [117]
3 years ago
7

Give a big-O estimate for the number additions used in this segment of an algorithm.

Computers and Technology
1 answer:
rjkz [21]3 years ago
3 0
Big-O notation is a way to describe a function that represents the n amount of times a program/function needs to be executed. 

(I'm assuming that := is a typo and you mean just =, by the way) 

In your case, you have two loops, nested within each other, and both loop to n (inclusive, meaning, that you loop for when i or j is equal to n), and both loops iterate by 1 each loop.

This means that both loops will therefore execute an n amount of times. Now, if the loops were NOT nested, our big-O would be O(2n), because 2 loops would run an n amount of times.

HOWEVER, since the j-loop is nested within i-loop, the j-loop executes every time the i-loop <span>ITERATES. 
</span>
As previously mentioned, for every i-loop, there would be an n amount of executions. So if the i-loop is called an n amount of times by the j loop (which executes n times), the big-O notation would be O(n*n), or O(n^2). 

(tl;dr) In basic, it is O(n^2) because the loops are nested, meaning that the i-loop would be called n times, and for each iteration, it would call the j-loop n times, resulting in n*n runs.

A way to verify this is to write and test program the above. I sometimes find it easier to wrap my head around concepts after testing them myself.
You might be interested in
ASAP BRAINLIEST!!!
Hoochie [10]

Answer:

none

Explanation:

6 0
3 years ago
What are the steps in preparing a bootable USB installer?​
never [62]

Answer:

it's actually complicated

ifctxoycpyypg

6 0
3 years ago
In 1-2 sentences, describe some keyboard shortcuts you have used during this lesson to save you time.
Aneli [31]
Command C command V command A
5 0
3 years ago
Read 2 more answers
Which way do you swipe in ios to get to the control center
Korvikt [17]

Answer:

Swipe down in the right corner or for older versions swipe from bottom

Explanation:

6 0
2 years ago
Sam and Ella are arguing in the cafeteria. Sam says that if he throws a chicken tender with a greater speed, it will have a grea
alexdok [17]
Ella im pretty suree let me know if im wrong
4 0
3 years ago
Read 2 more answers
Other questions:
  • Describe the Say It, Cover It, Resay It method.
    14·2 answers
  • How many rows and columns does ms-excel 2007 have???
    10·1 answer
  • Which of the following sentences uses the correct verb tense?
    8·2 answers
  • Match the following.
    8·2 answers
  • Write four overloaded methods called randomize. Each method will return a random number based on the parameters that it receives
    5·2 answers
  • Which option describes wearable technology?
    9·1 answer
  • A bluetooth network consists of _____ primary device(s) and up to ____ secondary devices.
    8·1 answer
  • Read two numbers from user input. Then, print the sum of those numbers. Hint - Copy/paste the following code, then just type cod
    9·1 answer
  • JUST NEED TO KNOW WHO ALL DOSE EDGINUITY
    12·2 answers
  • Select the correct answer from each drop-down menu.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!