-1
$\begingroup$

This question already has an answer here:

Hi I know two nested for loops will have time Complexity of O(n²). However let's say first loop starts from 0 and goes upto variable X max value(suppose x is n) and second loop starts from +1 of the first loop then we woudn't compare all the values of x with all the other values of x.In that case it woudn't be n². In that case +1 method cannot be O(n²) right? So what is it? Thanks.

$\endgroup$

marked as duplicate by Evil, Yuval Filmus algorithms Dec 21 '18 at 18:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0
$\begingroup$

In this example, you will do on total n x (n/2) = n²/2 iterations. This is better than n² of course... But still O(n²).

If you double n, the number of iterations growth by a factor 4.

$\endgroup$

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