Britannica Sources used in this answer

How does the size of an input affect an algorithm’s running time?

Created from Britannica articles using AI. AI can make mistakes, so verify using Britannica articles.

In the context of complexity, the running time of an algorithm is defined by its time complexity, which measures how the number of operations required grows as the size of the input, denoted as n, increases.1

Computer scientists use big-O notation to describe this growth, categorizing algorithms based on how their performance scales:

  • Constant time, O(1): The number of operations remains the same regardless of input size.1
  • Logarithmic time, O(log n): The time grows as a logarithm of n, which is highly efficient.1
  • Linear time, O(n): The running time increases proportionally with the input size.12
  • Quadratic time, O(n²): The time grows as the square of the input size, often seen in sorting algorithms.12
  • Exponential time, O(2ⁿ): The time required grows exponentially, making these algorithms often intractable for large inputs.12

Understanding these growth rates allows programmers to predict performance and select the most efficient algorithm for their specific needs.12