Alle boeken

Professioneel

Apps Over Coach Inloggen Begin met lezen

Computer Science · Begrippenlijst

Wat is Constant, linear, quadratic cost?

Definition 17.4 High School Computer Science · Hoofdstuk 17 — The Cost of an Algorithm

A cost is constant if it does not grow with nn; linear if it is about proportional to nn, so that doubling nn about doubles it; quadratic if it is about proportional to n2n^2, so that doubling nn about multiplies it by 44.

Worst-case counts, from figures/counts.py. At n = 100, 100 comparisons against 4950; the straight line is not zero, it only looks flat beside the parabola.
Worst-case counts, from figures/counts.py. At n=100n = 100, 100100 comparisons against 49504950; the straight line is not zero, it only looks flat beside the parabola.
Lees in het hoofdstuk →