Why they used "$=$ between a function and a set in algorithm.

78 Views Asked by At

I felt a little bit confused about the Theorem 3.1 from CLRS.

Here is the statement of this theorem:

For any two functions $f(n)$ and $g(n)$, we have $f(n) = \Theta(g(n))$ if and only if $f(n) = O(g(n))$ and $f(n) = \Omega(g(n))$, where $\Theta(g(n))$, $\Omega(g(n))$, and $O(g(n))$ are the sets of function, and $f(n)$ is a function.

In my opinion, we should use the notation "∈" instead of "=" in this case. Is that correct?

1

There are 1 best solutions below

2
On

I completely agree that strictly speaking, it is weird to use $=$ here, and $\in$ would be more correct. It does not conform to the standard meaning of $=$. It is, however, an ingrained convention, and that's ultimately what counts. Our modern mathematical language has plenty of confusing vestiges that because of tradition simply will not be changed.

There is one redeeming quality to this notation, however: Remainder terms. Say we are interested in the behavior of $f(x) = x^2 + \sin(x)$ when $x$ is very large. The sine term is basically irrelevant, so we want to somehow "discard" it (we can imagine that the sine term could be a lot more complicated, and difficult to deal with exactly, but still known to be bounded). One way to formulate this discarding is to write $$ f(x) = x^2 + O(1). $$ This way we are letting the $O(1)$ term not stand for the entire class of bounded functions, but as a generic placeholder for a bounded function that we don't really care a lot about. In this way it's not entirely different from the $C$ in indefinite integrals. Saying $f(x) = O(x^2)$ can be a way to simply let the entire function be the remainder term, especially if it's part of a larger argument.