count = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < i; j++)
count++;
What is the exact value of count in terms of n?
Answer: n(n-1)/2.
It sums 0 + 1 + 2 + ... + (n-1). This is the arithmetic series up to n-1.
Approx = n^2 / 2 = O(n^2).
for (i=0; iComplexity?
Show AnswerAnswer: O(n^3).
You have a function computeSquareRoot(double x).
Precondition: x >= 0.