Compare growth before choosing an algorithm
Enter an input size to evaluate constant, logarithmic, linear, linearithmic, quadratic, cubic, exponential and factorial growth. This Big-O complexity calculator compares explicit mathematical models. It does not inspect source code, count instructions in a program or prove a complexity bound. Use it alongside your Intro to Algorithms homework to see how a growth function changes as an input gets larger. The loaded comparison puts two concrete operation models side by side before the input fields, so you can start with an answer and then change the assumptions.
The input size must be a whole number from 1 through 1,000. Think of n as the number of records, array elements or vertices relevant to your model. Keep that meaning consistent between algorithms. An algorithm measured against the number of edges cannot be compared fairly with one measured against the number of vertices unless you first relate those quantities. Blank, fractional and out-of-range inputs clear the results instead of silently substituting an example.
What the eight functions mean
The constant function represents work that stays fixed in this model. The logarithmic function uses base two, a natural choice for repeated halving. Linear growth scales directly with input size, while n log₂ n combines a linear amount of work with logarithmically many levels. Quadratic and cubic functions describe stronger polynomial growth. The exponential function doubles whenever n increases by one. Factorial multiplies all positive integers through n and appears when considering permutations without pruning.
These are representative functions, not automatic classifications of every algorithm that uses a particular technique. A nested loop may stop early or iterate over different ranges. A recursive routine may make unequal subproblems. Write a recurrence or count the actual iterations before selecting a model. The master theorem calculator helps with supported divide-and-conquer recurrences. Bring the resulting growth function here to compare its scale with other functions.
Worked example: which algorithm is faster?
The loaded example sets n to 16, Algorithm A to 20n and Algorithm B to n². Running the calculation library gives 320 modeled operations for A and 256 for B. B uses less work at this input size even though its quadratic model grows faster eventually. Choose the larger-input example to set n to 32. The same models now give 640 for A and 1,024 for B, so A uses less work. The conclusion changes because the constant multiplier matters for a finite input.
You can edit either multiplier to represent an assumed cost per unit of growth. Multipliers are positive whole numbers through 1,000,000. They are illustrative operation costs, not measurements supplied by this site. If both models return the same value, the answer explicitly reports a tie. For these particular models, n equal to 20 gives 400 operations on each side. Use nearby input sizes to investigate a crossover, then check the algebra in your homework solution.
Compare sorting models
Choose the sorting example to compare n log₂ n with n² at n equal to 64. The library returns 384 and 4,096 respectively, with both multipliers set to one. These are growth-function values, not the exact comparison counts of merge sort or insertion sort. Their actual counts depend on implementation details and input order. Open the sorting algorithm visualizer to inspect concrete passes, swaps and comparisons on an array instead of assuming that a growth expression is a complete execution trace.
Exact values and rounded logarithms
The unscaled list evaluates all eight functions at your chosen n. Integer calculations use BigInt, preserving digits beyond ordinary floating-point integer precision. At n equal to 64, the exact value of 2ⁿ is 18446744073709551616. Long answers can be expanded to reveal every digit without filling the initial screen with a factorial. The list excludes the two comparison multipliers so you can distinguish a base function from a scaled algorithm model.
When a base-two logarithm is an integer, its value and the corresponding n log₂ n value are exact integers too. Otherwise the tool preserves an exact symbolic expression and labels the decimal with an approximation sign. At n equal to 10, log₂(10) is approximately 3.3219281 and 10 × log₂(10) is approximately 33.219281. Those decimals are rounded for display; they are not exact rational results.
Read the logarithmic chart
The chart samples input sizes from one through your chosen n. Its vertical axis shows log₁₀ of each function value, allowing factorial and linear growth to share a plot. Equal vertical distances represent multiplicative changes in work. Dashed line patterns match the legend. Values of zero cannot appear on a logarithmic axis, so log₂(1) and its linearithmic counterpart are omitted there; the exact-value list still shows them.
Big-O describes an asymptotic upper bound, whereas this page evaluates named functions at finite inputs. It cannot establish measured running time, memory consumption or a tight bound by itself. Use a benchmark for actual speed and a proof for a complexity claim. The chart helps build intuition after you have chosen a valid model.