Question: EX 2 . 5 Determine the growth function and order of the following code fragment: for ( int count = 0 ; count < n;

EX 2.5 Determine the growth function and order
of the following code fragment:
for (int count=0; count < n; count++){
for (int count2=1; count2
System.o ex4 EX 2.4 Determine the growth function and order
of the following code fragment:
for (int count=0; count < n; count++){
for (int count2=0; count2 ex4 for (int count =1; count <= n; count++)
{
printsum(count); // Is it constant time?
}
// print sum of all numbers from 1 to count
public void printsum(int count)
{
sum = count*(count+1)/2;
System.out.println (sum);
}ex5 for (int count =1; count <= n; count++)
{
printsum(count); // Is it constant time?
}
// print sum of all numbers from 1 to count
public void printsum(int count)
{
int sum =0;
for (int i =1; i <= count; i++) sum += i;
System.out.println(sum);
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!