Skip to content

Commit

Permalink
added BigO-notation.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjones320 committed Jan 8, 2024
1 parent 1b4c9fa commit 13cbc50
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions BigO-notation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
## **Step One: Simplifying Expressions**

Simplify the following big O expressions as much as possible:

1. O(n + 10) => O(n)

2. O(100 * n) => O(n)

3. O(25) => O(1)

4. O(n^2 + n^3) => O(n^3)

5. O(n + n + n + n) => O(n)

6. O(1000 * log(n) + n) => O(log(n)) ***O(n)

7. O(1000 * n * log(n) + n) => O(n * log(n))

8. O(2^n + n^2) => O(2^n)

9. O(5 + 3 + 1) => O(1)

10. O(n + n^(1/2) + n^2 + n * log(n)^10)
=> O(n * log(n)^10) ***O(n^2)


## **Step Two: Calculating Time Complexity**

1. O(n)

2. O(n)

3. O(1)

4. O(n^2) ***O(n)

5. O(n^2)

6. O(n)



## **Part 3 - short answer**

Answer the following questions

1. True or false: n^2 + n is O(n^2).
True
2. True or false: n^2 * n is O(n^3).
True
3. True or false: n^2 + n is O(n).
False
4. What’s the time complexity of the .indexOf array method?
O(n)
5. What’s the time complexity of the .includes array method?
O(n)
6. What’s the time complexity of the .forEach array method?
O(n)
7. What’s the time complexity of the .sort array method?
O(n log(n))
8. What’s the time complexity of the .unshift array method?
O(n)
9. What’s the time complexity of the .push array method?
O(1)
10. What’s the time complexity of the .splice array method?
O(n)
11. What’s the time complexity of the .pop array method?
O(1)
12. What’s the time complexity of the Object.keys() function?
O(n)
Bonus. What’s the space complexity of the Object.keys() function?
O(n)

0 comments on commit 13cbc50

Please sign in to comment.