Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

what is the role of the constant of proportionality while comparing the the order of complexities of two competing algorithms.

Like in case ALGO A has complexity 3*O(n) while ALGO B has complexity 10*O(n),What will be the effect of constant of 3 and 10 here?

share|cite|improve this question

The constants have no effect at all -- "$3\cdot O(n)$ and "$10\cdot O(n)$" both describe the same class of functions.

share|cite|improve this answer

The definition of f=O(g) is that there exists an n,m such that for every x>n, f(x) < M*g(x). that's why the constant doesn't matter. suppose ALGO A runs in 2*n binary operations, while ALGO B runs in n binary operations. then both run in O(n) time complexity.

share|cite|improve this answer
so what is the difference between ALGO A and B ??? – coder Apr 19 '12 at 12:12
This is hard to tell, since $3 \cdot O(n) = 10 \cdot O(n)$. The only thing we can say is that the algorithms take roughly linear time in the size of the input. – Johannes Kloos Apr 19 '12 at 12:19
@JohannesKloos: Strictly speaking, roughly linear time would be $\Theta(n)$, not $O(n)$. – Aryabhata Apr 19 '12 at 16:48
@Aryabhata: True, but that was roughly what I meant by "roughly" :) I tend to assume that an algorithm will consume all its input, so it will have $\Omega(n)$ time-complexity. – Johannes Kloos Apr 19 '12 at 17:36
@JohannesKloos: So, do you hate binary-search? :-) Just kidding... – Aryabhata Apr 19 '12 at 18:07

you can judge the importance of constant of proportionality by comparing insertion sort (c1.n^2),and merge sort(c2.nlogn). insertion sort is better when n is small,because of only single reason ie c1

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.