Search code examples
algorithmclrs

big O in algorithm


I have read the definition of big O in the introduction to algorithm which book doesn't talk about my confusion.

According to its definition, everybody knows the function T(n) = 3n belongs to O(n),my confusion is whether all functions what belongs to O(n) belongs to O(n^2) and O(n^3) and O(n^4) and O(n^k) k>1, because the big O describes the upper limit,and I aways can find the positive integer constant c and positive integer constant n0 to meet 0<=3n<=cn^2 when n>=n0, if the answer is YES, why do people prefer th use O(n) to describe T(n) = 3n if its definition is serious?

More, where are these notations(big O, big theta, big omega) been used in other math field?

Please post the necessary references or any other books which talk about this


Solution

  • A partial answer: your understanding is correct, O(n) is a strict subset of O(n^k) for k > 1.

    Why do we prefer O(n): If you ask for the price of some product (that actually costs 25) which answer would you prefer: a) at most 100 or b) at most 30. Saying that f(n) is in O(n) gives more information about f(n) than saying it is in O(n^2).

    Where else is it used? For example to describe the error term of an approximation.