Skip to content

Instantly share code, notes, and snippets.

@adslaton
Last active April 24, 2020 16:43
Show Gist options
  • Save adslaton/6e2a70412d5b0d85b5dcd761a526e9b5 to your computer and use it in GitHub Desktop.
Save adslaton/6e2a70412d5b0d85b5dcd761a526e9b5 to your computer and use it in GitHub Desktop.
Big O Linear Time
// 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