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
What is output when the CarTest application is run? Why?
erik [133]

Answer:

red

Explanation:

public class CarTest {

public static void main(String[] argvs) {

//below line will create an object of CarTest class Object

CarTest carTest = new CarTest();

//This will call runDemo method

carTest.runDemo();

}

public void runDemo() {

//Below line will create an object of Car class  with color blue and 4 wheel

Car c = new Car("blue", 4);

//Bellow Line will change the color from blue to red, see the logic writteen in chnageColor method definition

changeColor(c, "red");

//Below line will print the color as red

System.out.println(c.getColor());

}

public void changeColor(Car car, String newColor) {

//This line will set the color as passed color in the car object

car.setColor(newColor);

}

}

5 0
3 years ago
I need app ideas for basic everyday problems​
-BARSIC- [3]

Answer:

App that reminds you to drink water

Explanation:

A lot of people are dehydrated because they don't remeber to drink water

8 0
2 years ago
Which devices typically generate computer output ?
Andrews [41]
Monitor , printer , speaker , projector , keyboard etc
6 0
3 years ago
Read 2 more answers
White lines
kykrilka [37]

Answer:

Its B                                                                                                                                            

Explanation:

7 0
3 years ago
Read 2 more answers
What output is produced by
Natasha_Volkova [10]

Answer:

The answer to this question is given below in the explanation section. the correct option is C.

Explanation:

This is Java code statement:

System.out.print("Computing\nisInfun");

The output of this code statement is

Computing

isInfun

However, it is noted that the C option is not written correctly, but it is guessed that it will match to option C.

This Java code statement first prints "Computing" and then on the next line it will print "isInfun" because after the word "Computing" there is a line terminator i.e. \n. when \n will appear, the compiler prints the remaining text in the statement on the next line.

4 0
3 years ago
Other questions:
  • Whats the Sioux City school wifi?
    15·2 answers
  • This is pixlr
    6·1 answer
  • A finally clause will execute:
    8·1 answer
  • What is the importance of different camera angles ?
    9·2 answers
  • What is the difference between autofocus and autocomplete
    8·1 answer
  • What the central difference between negative and positive politeness?
    13·2 answers
  • A(n) ___ is a set of CPUs which work in parallel in an attempt to simulate the way the human brain works, although in greatly si
    5·1 answer
  • Identify and explain groups that may be impacted by nanotechnology.
    13·1 answer
  • Think of some local businesses that have websites. Look online and identify two different websites for businesses or services in
    11·1 answer
  • 2.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!