Questions tagged [big-o-notation]

Big O Notation is an informal name of the "O(x)" notation used to describe asymptotic behaviour of functions. It is a special case of Landau notation, where the O is the Greek letter capital omicron. Please consider using the [landau-notation] tag instead if your question is related to small omicron, omega, or theta in Landau notation.

Big O Notation is an informal name of the $\mathcal{O}(x)$ notation used to describe asymptotic behaviour of functions. It is a special case of .

353 questions
7
votes
3 answers

What are you allowed to move into the big O notation for it to be still correct?

Can someone tell me what the rules are for moving log or exponents into the $O(n)$ notation so it is still correct? For example: Is this $\log(O(n))= O(\log(n))$ correct? Or is this correct $O(n)^2=O(n^2)$? Or am I not allowed to do this?
OttoFran
  • 73
  • 1
  • 8
3
votes
3 answers

Find the error in the following “proof” that $O(n) = O(n^2)$

Let $f(n) = n^2 , g(n) = n$, and $h(n) = g(n)−f(n)$. It is clear that $h(n) ≤ g(n) ≤ f(n)$ for all $n ≥ 0$. Therefore, $f (n) = \max(f (n), h(n))$. Thus, $O(n) = O(g(n)) = O(f(n) + h(n)) = O(\max(f(n), h(n))) = O(f(n)) = O(n^2)$. Can you explain why…
Sonya
  • 97
  • 1
  • 2
  • 4
2
votes
2 answers

Does $f(n) \in O(g(n))$ imply $2^{f(n)} \in O(2^{g(n)})$?

Is the following true: $$ f(n) \in O(g(n)) \text{ then } 2 ^ {f(n)} \in O(2^{g(n)})$$
2
votes
3 answers

$\log_{2}{(\frac{1}{2}n)} + \log_{2}{(\frac{1}{4}n}) + \log_{2}{(\frac{1}{8}n)} + \ldots + \log_{2}{(\frac{1}{2^{log_{2}(n)}}n)} = O(\log_{2}(n))$?

I am trying to analyze a series that I found, in the analysis of an algorithm. And I was wondering if the following was true: $$\log_{2}{\left(\frac{1}{2}n\right)} + \log_{2}{\left(\frac{1}{4}n\right)} + \log_{2}{\left(\frac{1}{8}n\right)} + \cdots…
DenLilleMand
  • 169
  • 5
2
votes
2 answers

What do you get when you add $O(n)$ to itself $n$ times?

I was watching this video on Algorithms and counting number of inversions and he mentioned being cautions when $O(n) + O (n) = O(n)$, saying that is not true if you add $O(n)$ to itself $n$ times. Is the answer $O(n^2)$?
heretoinfinity
  • 659
  • 6
  • 16
2
votes
2 answers

Why is n log n dominated by n log^2 n?

Does the rule of $n ^ a$ dominate $n ^ b$ if $a > b$ apply here as well? My understanding is that $n \log n$ will be dominated by $n \log ^2 n$ because of $\log$ being raised to the power of $2$.
1
vote
2 answers

Asymptotics of $F(n) = n \times n^{\log_32}$

Is the complexity of $F(n) = n \cdot n^{\log_3 2}$ allowed to be written as $O(n)$, or must you specify and say $O(n^{1.63})$, or even must you write $O(n^2)$ since it is an upper bound?
1
vote
1 answer

Time complexity when taking certain elements and iterating over them?

I'm trying to gain a better understanding of Big O. Here is something that I'm unsure about. Say we have an array containing N elements that is inputted by the user. From my understanding iterating over each element from this array gives O(n) as we…
User361529
  • 11
  • 1
1
vote
1 answer

Possible Error in TAOCP

In section 1.2.11.2 of Donald Knuth's first volume of TAOCP, he gives an exercise at the end to prove that $g(n) = \Omega (f(n)) \iff f(n) = O(g(n))$ (exercise 13). His solution is simply: "we may take $L = \frac{1}{M}$ in the definitions of $O$ and…
Eli Yablon
  • 97
  • 6
1
vote
2 answers

Calculating Big O if unknown runtime of called functions

I haven't been able to track down if there is a generally accepted practice for assigning a Big O value when dealing with functions of unknown runtime. Given the following pseudocode, with two functions that operate in an unknown time, is it typical…
1
vote
2 answers

Is $O(\log x) = O(1)$?

A colleague recently brought up this argument when we were talking about big-O runtime analysis and I've been unable to find why it is incorrect: Informally, the argument goes like this: "If the runtime of all logarithms of any base are supposed to…
nitowa
  • 127
  • 2
1
vote
1 answer

why quicksort can have a best big o notation of (n log n)

Why does quicksort have a big $O$ notation of $(n \log n)$. I would like some help understanding what exactly $(n \log n)$ is, and then how it applies to quicksort. Also in $(n \log n)$, what is the base for the $\log$?
1
vote
1 answer

Simplify $O(\min(m, n))$?

I know that $O(\max(m, n)) = O(m + n)$, but is there a similar simplification for $O(\min(m, n))$? It could be $O(n) \cap O(m)$ but it does not simplify the notation that much…
scand1sk
  • 125
  • 1
  • 6
1
vote
1 answer

$g ( n ) ∈ ω ( 1 )$ and $f ( n ) ∈ o ( g ( n ) )$ imply $2 f ( n ) ∈ o ( 2 g ( n ) )$

Prove that if $g ( n ) ∈ ω ( 1 )$ and $f ( n ) ∈ o ( g ( n ) )$, then $2 f ( n ) ∈ o ( 2 g ( n ) )$. I was going over this question in my Algorithms class and could'nt understand why first condition has to be met. How would $g ( n ) ∈ ω ( 1 )$…
Rayan
  • 31
  • 1
1
vote
1 answer

What do these Big-O notations mean in context of comparison

What do the following mean, in the context of greater than, or smaller than? $$ O(n \log ⁡n) > O(n) $$ $$ O(nlogn) < O(n^2) $$
John Smith
  • 125
  • 5
1
2