For each of the following code fragments, give an analysis of the running time (Big-Oh notation). Be sure to show your work.
Question1:
sum = 0;
for (int i = 0; i < n; i++)
{ for (int j = 0; j < n; j++)
{
sum++;
}
}
Question2:
sum = 0;
for (int i = 0; i < n*n; i++)
{
sum++;
}
Question 3:
sum = 0;
for (int i = 1; i < =n; i=2)
{
for (int j = 0; j < =n; j++)
{
sum++;
}
}
For each of the following code fragments, give an analysis of the running time (Big-Oh notation)....