Big-O Solved

25.00 $

Category:

Description

5/5 - (3 votes)

Problems 1-10: Write the Big-O for each group of loops in the program(attached)

SHOW YOUR WORK for each of your answers. use any word processor to type the answers.

Steps to take to complete the selftest

1. Big-O is an estimate of how long a section of code takes to run.

2. For each problem, you need to ask yourself this question: “How many times will the loop repeat itself?”

3. O(1) means that the loop repeats a constant number of times. In other words, the loop repeats the same number of times, which is a small number.

4. O(log n) means that the counter is doubling, tripling, quadrupling, etc., so the loop repeats log(n) times. Usually, we are multiplying or dividing the loop counter.

5. O(n) means that the loop repeats the same number of times as n. Usually, we are adding to or subtracting from the loop counter.

6. O(2^n) means that the loop repeats the 2^n (2 to the power of n) number of times.

7. If the loops are nested, you multiply the Big-O terms, so O(1) is canceled out by the other Big-O terms.

8. If the loops are separate, you add the Big-O terms, so the largest (slowest run time) term cancels out all the smaller (faster run time) terms.

  • 10869825_sol.zip