Output-sensitive algorithm
≈ 2 min read
Names in other languages
No names in other languages are held for this entry yet.
Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.
In computer science, an output-sensitive algorithm is an algorithm whose running time depends on the size of the output, instead of, or in addition to, the size of the input. For certain problems where the output size varies widely, for example from linear in the size of the input to quadratic in the size of the input, analyses that take the output size explicitly into account can produce better runtime bounds that differentiate algorithms that would otherwise have identical asymptotic complexity.
In computer science, an output-sensitive algorithm is an algorithm whose running time depends on the size of the output, instead of, or in addition to, the size of the input. For certain problems where the output size varies widely, for example from linear in the size of the input to quadratic in the size of the input, analyses that take the output size explicitly into account can produce better runtime bounds that differentiate algorithms that would otherwise have identical asymptotic complexity. def divide(number: int, divisor: int) -> tuple[int, int]: """Division by subtraction.""" if divisor == 0: raise ZeroDivisionError if number = divisor: q += 1 r -= divisor return q, r Example output: >>> divide(10, 2) (5, 0) >>> divide(10, 3) (3, 1) This algorithm takes Θ(Q) time, and so can be fast in scenarios where the quotient Q is known to be small. In cases where Q is large however, it is outperformed by more complex algorithms such as long division. ==See also== Lazy evaluation
Text derived from https://en.wikipedia.org/w/index.php?oldid=1327938154 under CC BY-SA 4.0; modifications have been made.