Skip to content

Instantly share code, notes, and snippets.

@adslaton
Last active April 24, 2020 16:43
Show Gist options
  • Save adslaton/5be26ac7532731752f0b7626b1c9c1d2 to your computer and use it in GitHub Desktop.
Save adslaton/5be26ac7532731752f0b7626b1c9c1d2 to your computer and use it in GitHub Desktop.
Big O Quadratic Time
// Represents an algorithm whose performance is directly proportional to the squared size of the input data set
for (const x of Array(n).keys()) { // O(n)
for (const y of Array(n).keys()) { //
console.log(x, y); // O(n)
} //
}
// O(n) * O(n) * O(1) = O(n * n) = O(n^2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment