Big O Calculator
Calculate and visualize the time complexity of algorithms with Big O notation.
Constant (O(1)) Linear (O(n)) Quadratic (O(n²)) Logarithmic (O(log n)) Exponential (O(2^n))Not calculated yet.
Input Size: ${n}
Execution Time: ${time} ms
`; bigOSteps += `Selected Algorithm:
${complexity}
`; bigOSteps += `Explanation:
Big O Notation describes the upper bound of an algorithm’s growth rate based on the input size.
`; bigOSteps += `Tip: The higher the complexity, the more time it takes as the input grows. Exponential complexity grows very quickly as n increases.`; if(document.getElementById(“calculationStepsBigO”).style.display === “block”){ document.getElementById(“calculationStepsBigO”).innerHTML = bigOSteps; } } function resetBigO(){ document.querySelectorAll(“#calculator input”).forEach(el => el.value = “”); bigOSteps = “”; document.getElementById(“calculationStepsBigO”).innerHTML = “
Not calculated yet.
“; } function toggleBigOSteps(){ const s = document.getElementById(“calculationStepsBigO”); const a = document.getElementById(“toggleArrowBigO”); if(s.style.display === “none” || s.style.display === “”){ s.style.display = “block”; a.style.transform = “rotate(180deg)”; s.innerHTML = bigOSteps || “Not calculated yet.
“; } else { s.style.display = “none”; a.style.transform = “rotate(0deg)”; } }