Semua buku

Profesional

Aplikasi Tentang Pelatih Masuk Mulai membaca

Computer Science · Glosarium

Apa itu Complexity guarantee?

Definition 5.8 University Computer Science — Year 2 · Bab 5 — The Standard Library: Containers, Iterators and Algorithms

A complexity guarantee is a bound that the C++ standard imposes on an operation of the library, counted in operations on the elements (comparisons, copies, hash computations) as a function of the size: constant, logarithmic, linear, possibly amortised or on average. Every implementation must respect it; it says nothing of the constant factor.

The run of  on logarithmic axes. Both curves rise with a slope of about 2 (the list’s a little more), as O(n2) predicts; the list’s curve sits more than ten times higher for large n. Walking a vector reads consecutive bytes, which the processor fetches ahead; walking a list follows a pointer to a node whose address it learns only when the previous load completes.
The run of Output 5.8 on logarithmic axes. Both curves rise with a slope of about 2 (the list’s a little more), as O(n2)O(n^2) predicts; the list’s curve sits more than ten times higher for large nn. Walking a vector reads consecutive bytes, which the processor fetches ahead; walking a list follows a pointer to a node whose address it learns only when the previous load completes.
Baca dalam konteks →