PRASHNIKAप्रश्निका
Back to the paper

Compare the two complexities and and state which is better and why.

Computer Science20192 marksShort answer
Compare the two complexities $O(n^2)$ and $O(2^n)$ and state which is better and why.

Answer

Answer

AI
$O(n^2)$ is quadratic time complexity: the running time grows in proportion to the square of the input size $n$, typically produced by a nested loop (one loop inside another, both running about $n$ times). $O(2^n)$ is exponential time complexity: the running time doubles for every unit increase in $n$, typically produced by algorithms that try all possible subsets/combinations of the input. $O(n^2)$ is the better (more efficient) complexity, because exponential growth ($2^n$) increases far more rapidly than polynomial growth ($n^2$) as $n$ increases. For even moderately large $n$, $2^n$ becomes astronomically larger than $n^2$, making an $O(2^n)$ algorithm impractical for large inputs, whereas an $O(n^2)$ algorithm remains comparatively usable.
Complexity and Big O notation

From ISC 2019 Computer Science Paper 1, question 2(d).