Created
February 27, 2021 04:45
-
-
Save eengineergz/cc953ba2bd6e1d6f524a6d8b297aad5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// O(n) | |
function linear1(n) { | |
for (let i = 1; i <= n; i++) { | |
console.log(i); | |
} | |
} | |
// O(n), where n is the length of the array | |
function linear2(array) { | |
for (let i = 0; i < array.length; i++) { | |
console.log(i); | |
} | |
} | |
// O(n) | |
function linear3(n) { | |
if (n === 1) return; | |
linear3(n - 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment