Big O: O(n^2)
23 April 2023 (Updated 24 April 2023)
In a nutshell
An algorithm is considered O(n^2)
when its runtime increases by a factor of 2n relative to the input size.
export function printPairs(n: number): void {
for (let i = 0; i < n; i++) {
for (let j = 0; j < n; j++) {
console.log(i, j);
}
}
}
printPairs(5)
printPairs(10)
Tagged:
Big O Notation
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment