VerifiedEvidence: highv1.0.0

Time Complexity

A measure of how the execution time of an algorithm grows as the size of the input increases.

Last reviewedDarrin Baines IP Ltd

Concept Architecture

Concept

Theoretically, Time Complexity is the mathematical analysis of the computational time required by an algorithm as a function of input size. It is one of the fundamental measures of algorithmic efficiency and enables objective comparison of computational methods independently of computer hardware. Time complexity forms a core component of computational complexity theory and underpins the design and evaluation of algorithms used in health economic modelling, optimisation, simulation, and data analysis.

Mathematically, time complexity is expressed using asymptotic notation, most commonly Big O notation, which describes the growth rate of the number of elementary operations performed as the input size increases. Rather than measuring actual execution time, time complexity evaluates how computational effort scales with problem size by considering the dominant term of the algorithm.

In practice, time complexity is used to select efficient algorithms for large healthcare datasets, probabilistic sensitivity analyses, Monte Carlo simulations, pharmacometric models, optimisation methods, and machine learning applications. Understanding computational complexity allows analysts to predict scalability, estimate computational resources, and optimise model performance.

Purpose

Time complexity quantifies the computational effort required by an algorithm as input size increases, allowing comparison of alternative algorithms and supporting efficient implementation of computational methods in health economics and related disciplines.

Mathematical Formulae

Primary Formula

T(n) = O(f(n))

Where:

  • T(n) = time complexity
  • n = input size
  • f(n) = asymptotic growth function

Supporting Formulae

Total Running Time

T(n) = Number of Operations ? Cost per Operation

Common Complexity Classes

O(1) Constant time

O(log n) Logarithmic time

O(n) Linear time

O(n log n) Linearithmic time

O(n�) Quadratic time

O(n?) Cubic time

O(2�) Exponential time

O(n!) Factorial time

Related Mathematical Methods

  • Computational Complexity Theory
  • Big O Notation
  • Big Theta Notation
  • Big Omega Notation
  • Algorithm Analysis
  • Recurrence Relations
  • Divide and Conquer Analysis
  • Dynamic Programming
  • Numerical Algorithms
  • Computational Optimisation

Example

A health economic simulation analyses outcomes for 100,000 patients.

Algorithm A processes each patient once.

T(n) = O(n)

Algorithm B compares every patient with every other patient.

T(n) = O(n�)

As the dataset grows, Algorithm A scales efficiently, whereas Algorithm B becomes computationally expensive. Selecting the lower-complexity algorithm substantially reduces execution time for large healthcare models.

Excel Implementation

Input Size

=A2

Linear Operations

=A2

Logarithmic Operations

=LOG(A2,2)

Linearithmic Operations

=A2*LOG(A2,2)

Quadratic Operations

=A2^2

Cubic Operations

=A2^3

Complexity Classification

=CHOOSE(B2,"O(1)","O(LOG N)","O(N)","O(N LOG N)","O(N^2)","O(N^3)")

VBA (Optional)

Time complexity can be investigated in VBA by:

  • Counting algorithm iterations
  • Benchmarking alternative algorithms
  • Comparing recursive and iterative methods
  • Profiling execution time for increasing input sizes
  • Optimising simulation routines
  • Evaluating scalability of health economic models

Sources

Cormen TH, Leiserson CE, Rivest RL, Stein C. Introduction to Algorithms.

Knuth DE. The Art of Computer Programming.

Sipser M. Introduction to the Theory of Computation.

Aho AV, Hopcroft JE, Ullman JD. The Design and Analysis of Computer Algorithms.

Briggs AH, Claxton K, Sculpher MJ. Decision Modelling for Health Economic Evaluation.

Library

Publications

3
  • Book

    Computer Science Distilled — Wladston Ferreira Filho, 1st Edition ed., 2017 (Code Energy)

    A compact overview of foundational computer science, connecting algorithms, data structures, complexity, recursion, graphs and core computational ideas.

  • Book

    Algorithms Illuminated, Part 1: The Basics — Tim Roughgarden, 1st Edition ed., 2017 (Soundlikeyourself Publishing)

    An accessible introduction to algorithm analysis, asymptotic notation, divide-and-conquer design, recurrences and comparison-based sorting.

  • Book

    A Common-Sense Guide to Data Structures and Algorithms — Jay Wengrow, 2nd Edition ed., 2020 (The Pragmatic Bookshelf)

    A practical guide to data structures and algorithm efficiency, covering arrays, hashes, stacks, queues, trees, graphs, heaps, recursion and dynamic programming.

Frequently Asked Questions (6)

  • What is time complexity?

    A measure of how the execution time of an algorithm grows as the size of the input increases.

    Source: Algorithms and Theory of Computation Handbook. Asymptotic time complexity. In: Dictionary of Algorithms and Data Structures. NIST; 2004.

  • What does time complexity measure?

    Time complexity measures how the execution time of an algorithm grows as the size of the input increases. It describes the way running time scales with larger inputs rather than a fixed duration. Capturing this growth in execution time with input size is what time complexity does By describing how running time rises with input size, the measure predicts which algorithms stay usable as data grows, making it a central basis for comparing them.

    Source: Algorithms and Theory of Computation Handbook. Asymptotic time complexity. In: Dictionary of Algorithms and Data Structures. NIST; 2004.

  • Why is time complexity expressed in terms of input size?

    Time complexity is expressed in terms of input size because it measures how an algorithm's execution time changes as that size increases, and a single timing would not reveal how the algorithm scales. Relating running time to input size shows the trend for larger problems. This expression in terms of input size is central to time complexity By describing how running time rises with input size, the measure predicts which algorithms stay usable as data grows, making it a central basis for comparing them.

    Source: Algorithms and Theory of Computation Handbook. Asymptotic time complexity. In: Dictionary of Algorithms and Data Structures. NIST; 2004.

  • What resource does time complexity concern?

    Time complexity concerns execution time, measuring how the running time of an algorithm grows as the size of the input increases. It focuses on how long the algorithm takes rather than how much memory it uses. This concern with how running time scales is what defines time complexity By describing how running time rises with input size, the measure predicts which algorithms stay usable as data grows, making it a central basis for comparing them.

    Source: Algorithms and Theory of Computation Handbook. Asymptotic time complexity. In: Dictionary of Algorithms and Data Structures. NIST; 2004.

  • Why does time complexity matter when comparing algorithms?

    Time complexity matters when comparing algorithms because it measures how execution time grows with input size, and an algorithm that scales poorly may be far too slow on large inputs even if it is fast on small ones. Comparing time complexity predicts which stays practical as data grows. This bearing on scalability is why time complexity is used By describing how running time rises with input size, the measure predicts which algorithms stay usable as data grows, making it a central basis for comparing them.

    Source: Algorithms and Theory of Computation Handbook. Asymptotic time complexity. In: Dictionary of Algorithms and Data Structures. NIST; 2004.

  • How does time complexity relate to space complexity?

    Time complexity measures how the execution time of an algorithm grows as input size increases, while space complexity measures how its memory requirements grow with input size. The two describe different resources, time and memory, that scale with the input. They are connected as complementary measures of an algorithm's growing demands, sometimes traded off against one another By describing how running time rises with input size, the measure predicts which algorithms stay usable as data grows, making it a central basis for comparing them.

    Source: Algorithms and Theory of Computation Handbook. Asymptotic time complexity. In: Dictionary of Algorithms and Data Structures. NIST; 2004.

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 16 Jun 2026

Content version: 1.0.0

Canonical Identity

Term code
CS-SC-PF-002

Stable URI · Machine-readable · Resolvable · CC BY 4.0