Lower Bounds

Big-O notation describes an upper bound. In other words, big-O notation states a claim about the greatest amount of some resource (usually time) that is required by an algorithm for some class of inputs of size \(n\) (typically the worst such input, the average of all possible inputs, or the best such input).

Similar notation is used to describe the least amount of a resource that an algorithm needs for some class of input. Like big-O notation, this is a measure of the algorithm’s growth rate. Like big-O notation, it works for any resource, but we most often measure the least amount of time or storage required. And again, like big-O notation, we are measuring the resource required for some particular class of inputs: the worst-, average-, or best-case input of size \(n\).

The lower bound for an algorithm (or a problem, as explained later) is denoted by the symbol \(\Omega\), pronounced “big-Omega” or just “Omega”. The following definition for \(\Omega\) is symmetric with the definition of big-O.

For \(\mathbf{T}(n)\) a non-negatively valued function, \(\mathbf{T}(n)\) is in set \(\Omega(g(n))\) if there exist two positive constants \(c\) and \(n_0\) such that \(\mathbf{T}(n) \geq c g(n)\) for all \(n > n_0\).

It is also true that the equation of the example above is in \(\Omega(n)\). However, as with big-O notation, we wish to get the “tightest” (for \(\Omega\) notation, the largest) bound possible. Thus, we prefer to say that this running time is in \(\Omega(n^2)\).

Recall the sequential search algorithm to find a value \(K\) within an array of integers. In the average and worst cases this algorithm is in \(\Omega(n)\), because in both the average and worst cases we must examine at least \(cn\) values (where \(c\) is 1/2 in the average case and 1 in the worst case).

An alternate definition

An alternate (non-equivalent) definition for \(\Omega\) is

\(\mathbf{T}(n)\) is in the set \(\Omega(g(n))\) if there exists a positive constant \(c\) such that \(\mathbf{T}(n) \geq c g(n)\) for an infinite number of values for \(n\).

This definition says that for an “interesting” number of cases, the algorithm takes at least \(c g(n)\) time. Note that this definition is not symmetric with the definition of big-O. For \(g(n)\) to be a lower bound, this definition does not require that \(\mathbf{T}(n) \geq c g(n)\) for all values of \(n\) greater than some constant. It only requires that this happen often enough, in particular that it happen for an infinite number of values for \(n\). Motivation for this alternate definition can be found in the following example.

Assume a particular algorithm has the following behavior:

\[\begin{split}\mathbf{T}(n) = \left\{ \begin{array}{ll} n & \mbox{for all odd}\ n \geq 1\\ n^2/100 & \mbox{for all even}\ n \geq 0 \end{array} \right.\end{split}\]

From this definition, \(n^2/100 \geq \frac{1}{100} n^2\) for all even \(n \geq 0\). So, \(\mathbf{T}(n) \geq c n^2\) for an infinite number of values of \(n\) (i.e., for all even \(n\)) for \(c = 1/100\). Therefore, \(\mathbf{T}(n)\) is in \(\Omega(n^2)\) by the definition.

For this equation for \(\mathbf{T}(n)\), it is true that all inputs of size \(n\) take at least \(cn\) time. But an infinite number of inputs of size \(n\) take \(cn^2\) time, so we would like to say that the algorithm is in \(\Omega(n^2)\). Unfortunately, using our first definition will yield a lower bound of \(\Omega(n)\) because it is not possible to pick constants \(c\) and \(n_0\) such that \(\mathbf{T}(n) \geq c n^2\) for all \(n>n_0\). The alternative definition does result in a lower bound of \(\Omega(n^2)\) for this algorithm, which seems to fit common sense more closely. Fortunately, few real algorithms or computer programs display the pathological behavior of this example. Our first definition for \(\Omega\) generally yields the expected result.

Clearly asymptotic bounds notation is not a law of nature. It is merely a powerful modeling tool used to describe the behavior of algorithms.

Theta Notation

The definitions for big-O and \(\Omega\) give us ways to describe the upper bound for an algorithm (if we can find an equation for the maximum cost of a particular class of inputs of size \(n\)) and the lower bound for an algorithm (if we can find an equation for the minimum cost for a particular class of inputs of size \(n\)). When the upper and lower bounds are the same within a constant factor, we indicate this by using \(\Theta\) (big-Theta) notation. An algorithm is said to be \(\Theta(h(n))\) if it is in \(O(h(n))\) and it is in \(\Omega(h(n))\). Note that we drop the word “in” for \(\Theta\) notation, because there is a strict equality for two equations with the same \(\Theta\). In other words, if \(f(n)\) is \(\Theta(g(n))\), then \(g(n)\) is \(\Theta(f(n))\).

Because the sequential search algorithm is both in \(O(n)\) and in \(\Omega(n)\) in the average case, we say it is \(\Theta(n)\) in the average case.

Given an algebraic equation describing the time requirement for an algorithm, the upper and lower bounds always meet. That is because in some sense we have a perfect analysis for the algorithm, embodied by the running-time equation. For many algorithms (or their instantiations as programs), it is easy to come up with the equation that defines their runtime behavior. The analysis for most commonly used algorithms is well understood and we can almost always give a \(\Theta\) analysis for them. However, the class of NP-Complete problems all have no definitive \(\Theta\) analysis, just some unsatisfying big-O and \(\Omega\) analyses.

Even some “simple” programs are hard to analyze. Consider the Collatz Conjecture. The Collatz Conjecture or 3x+1 problem can be summarized as follows:

Take any positive integer \(n\). If \(n\) is even, divide \(n\) by 2. If \(n\) is odd, multiply \(n\) by 3 and add 1. Repeat the process indefinitely. The conjecture states that no matter which number you start with, you will always reach 1 eventually.

Nobody currently knows the true upper or lower bounds for the conjecture, because it is unknown if it is true.

while n > 1
   if n is odd
      n  3*n + 1
   else
      n  n / 2
   done if
done while

While some textbooks and programmers will casually say that an algorithm is “order of” or “big-O” of some cost function, it is generally better to use \(\Theta\) notation rather than big-O notation whenever we have sufficient knowledge about an algorithm to be sure that the upper and lower bounds indeed match. We will use \(\Theta\) notation in preference to big-O notation whenever our state of knowledge makes that possible. Limitations on our ability to analyze certain algorithms may require use of big-O or \(\Omega\) notations. In rare occasions when the discussion is explicitly about the upper or lower bound of a problem or algorithm, the corresponding notation will be used in preference to \(\Theta\) notation.

Classifying Functions

Given functions \(f(n)\) and \(g(n)\) whose growth rates are expressed as algebraic equations, we might like to determine if one grows faster than the other. The best way to do this is to take the limit of the two functions as \(n\) grows towards infinity,

\[\lim_{n \rightarrow \infty} \frac{f(n)}{g(n)}.\]

If the limit goes to \(\infty\), then \(f(n)\) is in \(\Omega(g(n))\) because \(f(n)\) grows faster. If the limit goes to zero, then \(f(n)\) is in \(O(g(n))\) because \(g(n)\) grows faster. If the limit goes to some constant other than zero, then \(f(n) = \Theta(g(n))\) because both grow at the same rate.

Pitfall: Confusing lower bound and best case

A common mistake people make is confusing the lower bound and best case cost for an algorithm. In part this is because for simple algorithms, they look just like the upper bound.

The lower bound represents the least cost an algorithm needs for a problem of size \(n\).

In the best case, only a single element is visited. Accordingly, the lower bound for this algorithm in the best case is \(\Omega(1)\). Even when \(n\) grows large, the cost for the base case is constant.

In the worst case, every element is visited. \(\Omega(n)\) is a lower bound for the cost of the algorithm in the worst case because the worst case must always examine \(n\) records.

In the average case, about \(\frac{n}{2}\) elements are visited. The lower bound for this algorithm in the average case is also \(\Omega(n)\). As \(n\) grows large, the denominator becomes insignificant. No matter the value of \(n\), for some constant \(c\), \(cn\) is less than or equal to the average cost of \(n/2\).

For this simple algorithm the upper and lower bounds are the same in the best / average / worst case:

  • \(O(1)\) in the best case

  • \(O(n)\) in the worst case

  • \(O(n)\) in the average case

Then why do we have upper and lower bounds in the first place, if they work out to be the same?

In the case of functions like sequential search that are perfectly understood, they are the same. The upper and lower bound will only be different when we are describing what we know about an algorithm that we don’t know the exact cost for.

This is what \(\Theta\) is for. It is a shorthand we use to say the upper and lower bounds match. We can say the cost is \(\Theta\) some value.

Sequential search has worst case cost \(\Theta(n)\) because the upper and lower bounds are the same.

Self Check

More to explore

You have attempted of activities on this page