{
  "id": "big-theta-notation",
  "title": "Big-Theta Notation",
  "lang": "en",
  "source_lang": "en",
  "summary": "Big-Theta notation describes an asymptotically tight bound on a function’s growth, ignoring constant factors and behavior on sufficiently small inputs.",
  "category": "computer-science",
  "subcategory": "algorithms-theory",
  "type": "concept",
  "aliases": [
    "Theta notation",
    "Θ notation",
    "asymptotically tight bound notation"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/big-theta-notation/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/big-theta-notation/",
      "json": "https://aiwiki.page/zh/big-theta-notation.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Big-Theta notation, written \\(\\Theta\\), describes functions that grow at the same rate up to positive constant factors as their argument becomes sufficiently large. In computer science, it is used to express tight bounds on the resources required by an algorithm, especially running time and memory. A statement such as \\(T(n)=\\Theta(n^2)\\) means that, beyond some input size, \\(T(n)\\) is bounded both above and below by positive constant multiples of \\(n^2\\). It does not specify an exact running time or require the ratio \\(T(n)/n^2\\) to approach a limit."
    },
    {
      "heading": "Formal definition",
      "text": "Let \\(f\\) and \\(g\\) be real-valued functions of a positive integer \\(n\\), with both functions nonnegative for all sufficiently large \\(n\\). The set \\(\\Theta(g(n))\\) consists of all functions \\(f\\) for which there exist constants \\(c_1>0\\), \\(c_2>0\\), and \\(n_0\\) such that\n\n\\[0\\leq c_1g(n)\\leq f(n)\\leq c_2g(n) \\qquad\\text{for every }n\\geq n_0.\\]\n\nThe constants must be independent of \\(n\\), though they may depend on the particular functions being compared.\n\nThe lower inequality prevents \\(f\\) from becoming arbitrarily small relative to \\(g\\); the upper inequality prevents it from becoming arbitrarily large relative to \\(g\\). Both must hold for every sufficiently large argument, not merely for infinitely many arguments.\n\nStrictly speaking, the notation expresses membership in a set of functions:\n\n\\[f\\in\\Theta(g).\\]\n\nThe conventional form\n\n\\[f(n)=\\Theta(g(n))\\]\n\nuses the equals sign as shorthand for this membership relation. It should not be interpreted as ordinary equality between a function and a set.\n\nFor functions that can take negative values, an absolute-value definition is also used:\n\n\\[c_1|g(n)|\\leq |f(n)|\\leq c_2|g(n)|\\]\n\nfor all sufficiently large \\(n\\). In algorithm analysis, resource counts are normally nonnegative, so the nonnegative definition is usually sufficient."
    },
    {
      "heading": "Relationship to other asymptotic notations",
      "text": "Big-Theta is part of asymptotic analysis, which studies limiting behavior rather than exact values at every argument.\n\nThe two bounds in its definition correspond to two other notations:\n\n- Big-O notation, \\(f(n)=O(g(n))\\), gives an asymptotic upper bound.\n- Big-Omega notation, \\(f(n)=\\Omega(g(n))\\), gives an asymptotic lower bound.\n\nUnder the same nonnegativity assumptions,\n\n\\[f(n)=\\Theta(g(n)) \\quad\\Longleftrightarrow\\quad f(n)=O(g(n)) \\ \\text{and}\\ f(n)=\\Omega(g(n)).\\]\n\nThus, a Theta bound is asymptotically tight: its upper and lower bounds agree up to constant factors.\n\nFor example, \\(n^2=O(n^3)\\) is correct, but it is not tight. The statement \\(n^2=\\Theta(n^3)\\) is false because no positive constant multiple of \\(n^3\\) remains below \\(n^2\\) for all sufficiently large \\(n\\).\n\nTheta versus asymptotic equivalence\n\nAsymptotic equivalence, written \\(f(n)\\sim g(n)\\), usually means\n\n\\[\\lim_{n\\to\\infty}\\frac{f(n)}{g(n)}=1.\\]\n\nThis is stronger than a Theta relationship. For instance,\n\n\\[3n^2\\sim 3n^2+n,\\]\n\nbut \\(3n^2\\not\\sim n^2\\), even though \\(3n^2=\\Theta(n^2)\\).\n\nMore generally, if\n\n\\[\\lim_{n\\to\\infty}\\frac{f(n)}{g(n)}=L, \\qquad 0<L<\\infty,\\]\n\nthen \\(f(n)=\\Theta(g(n))\\). A limit is sufficient, however, not necessary. The ratio can oscillate while staying between positive constants."
    },
    {
      "heading": "Examples and proof methods",
      "text": "Polynomial growth\n\nConsider\n\n\\[f(n)=3n^2+5n+7.\\]\n\nFor \\(n\\geq1\\), both \\(n\\leq n^2\\) and \\(1\\leq n^2\\), so\n\n\\[3n^2\\leq 3n^2+5n+7\\leq15n^2.\\]\n\nChoosing \\(c_1=3\\), \\(c_2=15\\), and \\(n_0=1\\) proves\n\n\\[3n^2+5n+7=\\Theta(n^2).\\]\n\nIn general, a polynomial with positive leading coefficient has the same asymptotic order as its highest-degree term. Lower-degree terms and fixed multiplicative constants do not change its Theta class.\n\nCounting repeated operations\n\nSuppose an algorithm performs a constant-time operation \\(i\\) times during outer-loop iteration \\(i\\), for \\(i=1,\\ldots,n\\). The total operation count is\n\n\\[\\sum_{i=1}^{n}i=\\frac{n(n+1)}{2}=\\Theta(n^2).\\]\n\nThis illustrates why nested loops do not have to execute the same number of inner iterations to yield quadratic growth. The relevant quantity is the total number of operations.\n\nLogarithmic growth\n\nFor fixed bases \\(a,b>1\\),\n\n\\[\\log_a n=\\frac{\\log_b n}{\\log_b a}.\\]\n\nBecause the conversion factor is a positive constant,\n\n\\[\\log_a n=\\Theta(\\log_b n).\\]\n\nConsequently, the logarithm’s base is often omitted in asymptotic resource bounds. This simplification does not apply to exponential bases: \\(2^n\\) and \\(3^n\\) are not Theta-equivalent.\n\nOscillation\n\nFor positive integers \\(n\\), let\n\n\\[f(n)=n\\bigl(2+(-1)^n\\bigr).\\]\n\nIts value is either \\(n\\) or \\(3n\\), so\n\n\\[n\\leq f(n)\\leq3n.\\]\n\nTherefore \\(f(n)=\\Theta(n)\\), even though \\(f(n)/n\\) has no limit. Theta notation describes bounded relative growth, not convergence to a fixed ratio."
    },
    {
      "heading": "Use in algorithm analysis",
      "text": "In computational complexity, Theta notation commonly describes time complexity and space complexity as functions of input size.\n\nTypical examples include:\n\nAlgorithm or operation | Tight bound | Assumptions\nAccessing an element of an [[array-data-structure | array]] by index | \\(\\Theta(1)\\)\n[[binary-search | Binary search]] | \\(\\Theta(\\log n)\\) worst-case comparisons\n[[merge-sort | Merge sort]] | \\(\\Theta(n\\log n)\\) worst-case time\n[[insertion-sort | Insertion sort]] | \\(\\Theta(n^2)\\) worst-case time\n\nThe resource and computational model matter. An arithmetic operation on fixed-size machine words may be treated as constant time, whereas arithmetic on arbitrarily large integers generally depends on the number of bits involved.\n\nWorst case, average case, and amortized cost\n\nTheta notation does not itself specify which inputs or executions are being analyzed.\n\nFor an algorithm whose running time on input \\(x\\) is \\(T(x)\\), a worst-case function can be defined as\n\n\\[T_{\\mathrm{worst}}(n)=\\max_{|x|=n}T(x).\\]\n\nA statement \\(T_{\\mathrm{worst}}(n)=\\Theta(g(n))\\) tightly bounds that maximum. It does not say that every input of size \\(n\\) takes \\(\\Theta(g(n))\\) time.\n\nAn average-case bound concerns an expected value under a specified distribution of inputs. For a randomized algorithm, an expected bound may instead concern the algorithm’s internal random choices. These are different sources of randomness and must be identified.\n\nIn amortized analysis, a bound concerns the cost of a sequence of operations, rather than necessarily the cost of each operation individually. Appending to a dynamic array with geometric capacity growth can take \\(\\Theta(n)\\) time when a resize copies \\(n\\) existing elements, while having amortized \\(\\Theta(1)\\) cost per append."
    },
    {
      "heading": "Algebraic properties",
      "text": "For eventually positive functions, having the same Theta class is an equivalence relation:\n\n- Reflexivity: \\(f=\\Theta(f)\\).\n- Symmetry: if \\(f=\\Theta(g)\\), then \\(g=\\Theta(f)\\).\n- Transitivity: if \\(f=\\Theta(g)\\) and \\(g=\\Theta(h)\\), then \\(f=\\Theta(h)\\).\n\nUseful calculation rules include the following.\n\nFor a positive constant \\(a\\),\n\n\\[af=\\Theta(f).\\]\n\nFor eventually nonnegative \\(f\\) and \\(g\\),\n\n\\[f+g=\\Theta(\\max\\{f,g\\}).\\]\n\nIf \\(f_1=\\Theta(g_1)\\) and \\(f_2=\\Theta(g_2)\\), with all functions eventually positive, then\n\n\\[f_1f_2=\\Theta(g_1g_2),\\]\n\nand\n\n\\[\\frac{f_1}{f_2}=\\Theta\\!\\left(\\frac{g_1}{g_2}\\right).\\]\n\nSubtraction requires care because cancellation can remove the dominant term. Knowing that \\(f=\\Theta(n^2)\\) and \\(g=\\Theta(n^2)\\) does not determine the order of \\(f-g\\). For example, if \\(f(n)=n^2+n\\) and \\(g(n)=n^2\\), then \\(f(n)-g(n)=n\\)."
    },
    {
      "heading": "Scope and limitations",
      "text": "Theta notation deliberately discards constant factors and finite initial behavior. Two implementations in the same Theta class may differ greatly in actual running time because of memory access patterns, hardware, compiler optimizations, or large hidden constants. An asymptotically slower algorithm can outperform another over a practically relevant range of input sizes.\n\nA Theta bound also does not establish that an algorithm is optimal. An algorithm with running time \\(\\Theta(n^2)\\) has a tight description of its own growth; proving optimality requires a suitable lower bound for all algorithms solving the problem within the stated model.\n\nInput size must be defined carefully. If an integer has numerical value \\(N\\), its binary representation has length \\(\\Theta(\\log N)\\). A running time linear in \\(N\\) is therefore exponential in that representation length.\n\nFor functions of several variables, the domain and quantifiers must also be specified. In a bound such as \\(\\Theta(n+m)\\), the multiplicative constants must be uniform over the stated range of \\(n\\) and \\(m\\). Treating one parameter as fixed can produce a different claim from allowing both to vary independently."
    }
  ],
  "links": [
    "computer-science",
    "algorithm",
    "mathematical-function",
    "big-o-notation",
    "big-omega-notation",
    "polynomial",
    "computational-complexity",
    "time-complexity",
    "space-complexity",
    "array-data-structure",
    "binary-search",
    "merge-sort",
    "insertion-sort",
    "expected-value",
    "randomized-algorithm",
    "amortized-analysis",
    "dynamic-array",
    "compiler"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}