Asymptotic Bounds and Input Models

Interpret running-time bounds with several input parameters and account for the encoding length of numeric inputs.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Keep parameters visible
  2. Count bits and machine operations separately

Keep parameters visible

An adjacency-list traversal of a graph with \(n\) vertices and \(m\) edges takes \(O(n+m)\) work if each edge entry is scanned once. For a simple graph, the bound implies \(O(n^2)\), but that loses the linear behavior when \(m=O(n)\). For a multigraph, \(m\) can exceed \(n^2\). Specify which inputs vary and which constraints relate them. For example, breadth-first search can scan an adjacency matrix in \(O(n^2)\) regardless of the number of stored edges.

Count bits and machine operations separately

A loop with \(W\) iterations is linear in the value \(W\). With \(W=2^b-1\), the input represents that value in \(b\) binary digits, so the loop is exponential in the encoding length. This distinction explains the name pseudopolynomial time. Also state which arithmetic operations the model treats as unit cost. Comparing algorithms that manipulate small indices is different from comparing methods whose intermediate integers grow to thousands of bits, as in bit complexity.[1][2]

References

  1. MIT OpenCourseWare, Introduction to Algorithms: Lecture Notes ↩
  2. Eric Lehman, F. Thomson Leighton and Albert R. Meyer, Mathematics for Computer Science ↩