Determine for the following code fragments in the average case. Assume that all variables are of

Question:

Determine Θ for the following code fragments in the average case. Assume that all variables are of type int.

a. a = b + c; d = a + e;

b.

sum = 0; for (i=0; i <3; i++) for (j=0; j

c.

sum=0; for (i=0; i

d.

for (i=0; i < n-1; i++) for (j=i+1; j

e.

sum = 0; for (i=1; i

f.

sum = 0; for (i=1; i

g. Assume that array A contains n values, Random takes constant time, and sort takes n log n steps.

for (i=0; i

h. Assume array A contains a random permutation of the values from 0 to n - 1.

sum = 0; if (EVEN (n)) for (i=0; i

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: