Skip to content

Commit 13cbc50

Browse files
committed
added BigO-notation.txt
1 parent 1b4c9fa commit 13cbc50

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

BigO-notation.txt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## **Step One: Simplifying Expressions**
2+
3+
Simplify the following big O expressions as much as possible:
4+
5+
1. O(n + 10) => O(n)
6+
7+
2. O(100 * n) => O(n)
8+
9+
3. O(25) => O(1)
10+
11+
4. O(n^2 + n^3) => O(n^3)
12+
13+
5. O(n + n + n + n) => O(n)
14+
15+
6. O(1000 * log(n) + n) => O(log(n)) ***O(n)
16+
17+
7. O(1000 * n * log(n) + n) => O(n * log(n))
18+
19+
8. O(2^n + n^2) => O(2^n)
20+
21+
9. O(5 + 3 + 1) => O(1)
22+
23+
10. O(n + n^(1/2) + n^2 + n * log(n)^10)
24+
=> O(n * log(n)^10) ***O(n^2)
25+
26+
27+
## **Step Two: Calculating Time Complexity**
28+
29+
1. O(n)
30+
31+
2. O(n)
32+
33+
3. O(1)
34+
35+
4. O(n^2) ***O(n)
36+
37+
5. O(n^2)
38+
39+
6. O(n)
40+
41+
42+
43+
## **Part 3 - short answer**
44+
45+
Answer the following questions
46+
47+
1. True or false: n^2 + n is O(n^2).
48+
True
49+
2. True or false: n^2 * n is O(n^3).
50+
True
51+
3. True or false: n^2 + n is O(n).
52+
False
53+
4. What’s the time complexity of the .indexOf array method?
54+
O(n)
55+
5. What’s the time complexity of the .includes array method?
56+
O(n)
57+
6. What’s the time complexity of the .forEach array method?
58+
O(n)
59+
7. What’s the time complexity of the .sort array method?
60+
O(n log(n))
61+
8. What’s the time complexity of the .unshift array method?
62+
O(n)
63+
9. What’s the time complexity of the .push array method?
64+
O(1)
65+
10. What’s the time complexity of the .splice array method?
66+
O(n)
67+
11. What’s the time complexity of the .pop array method?
68+
O(1)
69+
12. What’s the time complexity of the Object.keys() function?
70+
O(n)
71+
Bonus. What’s the space complexity of the Object.keys() function?
72+
O(n)

0 commit comments

Comments
 (0)