Linear complexity and quadratic complexity
Posted
by jasonline
on Stack Overflow
See other posts from Stack Overflow
or by jasonline
Published on 2010-05-05T09:15:17Z
Indexed on
2010/05/05
10:18 UTC
Read the original article
Hit count: 407
I'm just not sure...
If you have a code that can be executed in either of the following complexities:
- A sequence of O(n), like for example: two O(n) in sequence
- O(n²)
The preferred version would be the one that can be executed in linear time. Would there be a time such that the sequence of O(n) would be too much and that O(n²) would be preferred? In other words, is the statement C x O(n) < O(n²) always true for any constant C?
Why or why not? What are the factors that would affect the condition such that it would be better to choose the O(n²) complexity?
© Stack Overflow or respective owner