File tree Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Original file line number Diff line number Diff line change
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)
You can’t perform that action at this time.
0 commit comments