Monique W.

asked • 07/29/16

The Big O Notation

Suppose we are given the following program segment:

F(x) = 0
Input n
For x = 1 to x = n
y = x*(x+3)+2
Print y
Next x

1. Determine the number of steps the program will execute before entering the loop.
2. Determine the number of steps the program will execute each time it passes through the loop.
3. Determine the total number of steps that will be executed by the program if the value of n is 3,4,5
4. Determine a function that provides the number of steps that will be executed for a general value of n. You should be able to incorporate your work from steps 1 -3 to help you develop a function in the form f(n) = ... When you compute f(3), f(4), and f(5), you should get your results for step 3.
5. Using the definition of O, show that the function f you found in step 4 is O(n). This means that the algorithm is O(n)

1 Expert Answer

By:

David W. answered • 07/29/16

Tutor
4.7 (90)

Experienced Prof

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.