Last active
April 24, 2020 16:43
-
-
Save adslaton/6e2a70412d5b0d85b5dcd761a526e9b5 to your computer and use it in GitHub Desktop.
Big O Linear Time
This file contains hidden or 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
// Represents an algorithm who’s complexity will grow in direct proportion to the size of the input data | |
// 1. | |
for (const x of Array(n).keys()) { // n | |
console.log(x); // O(1) | |
} | |
// n * O(1) = O(n) | |
// 2. | |
y = 1 + 2; // O(1) | |
for (const x of Array(n).keys()) { // | |
console.log(x, y); // O(n) | |
} // | |
// O(1) + O(n) = O(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment