[Solved] Big-O

$25

File Name: Big-O.zip
File Size: 47.1 KB

SKU: [Solved] Big-O Category: Tag:
5/5 - (1 vote)

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.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] Big-O
$25