Todos os livros

Profissional

Apps Sobre Coach Entrar Começar a ler

Computer Science · Glossário

O que é Constant, linear, quadratic cost?

Definition 17.4 High School Computer Science · Capítulo 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.
Ler no capítulo →