We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9e87ee8 commit 99bb458Copy full SHA for 99bb458
src/big-O-complexities/big-O-complexities-01.ts
@@ -0,0 +1,24 @@
1
+/**
2
+ * Big-O complexities
3
+ *
4
+ * O(1) is constant time.
5
+ * O(1) does not change with respect to input space.
6
+ * Hence, O(1) is referred to as being constant time.
7
+ * An example of an O(1) algorithm is accessing an item in the array by its index.
8
9
+ * O(n) is linear time.
10
+ * O(n) is linear time and applies to algorithms that must do n operations in the worst-case scenario.
11
12
+ * O(n2) is quadratic time,
13
14
+ * O(n3) is cubic time.
15
+
16
17
+ */
18
19
+// O(n) algorithm is printing numbers from 0 to n-1
20
+function printLinerTime(n: number) {
21
+ for (let i = 0; i < n; i++) {
22
+ console.log(i);
23
+ }
24
+}
0 commit comments