Skip to content

Commit 99bb458

Browse files
author
Wakidur Rahaman
committed
PrintLinerTime function implement.
1 parent 9e87ee8 commit 99bb458

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)