Determine the precise big-oh values for each of the


Question: Determine the precise (i.e., not just the order of magnitude) Big-Oh values for each of the following code samples, based on the number of statement executions.

The answer should be in the form of a Big-Oh polynomial (e.g., O(3N2 + 7N + 6))

Please show all the working and provide the answer.    

Keep the subsequent considerations in mind:

  • Remember to consider each statement in compound statements separately.
  • Pay close attention to the initial and end values of loop variables!
  • Loops such as "for" and "while" contain an implicit "jump" instruction that causes execution to proceed from the end of the loop back to the beginning of the loop.

Sample #1:

int i = 0;

int j = 1;

Sample #2:

for (int i = 0; i < n; i++)

{

sum += i;

}

int j = 0;

while (j < n)

{

sum--;

j++;

}

Sample #3:

for (int i = 0; i < n; i++)

{

for (int j = 0; j < n; j++)

{

sum += i;

}

}

Sample #4:

for (int i = 0; i < n; i++)

{

sum += i;

}

for (int j = 0; j < n; j++)

{

for (int k = 0; k < n; k++)

{

sum--;

}

}

Sample #5:

for (int i = 0; i < n; i++)

{

for (int j = i; j < n; j++)

{

for (int k = j; k < n; k++)

{

sum += j;

}

}

}

Add comments in code section. Code this program in java programming - Please keep it simple and short and no copy and paste or at least help me get started?

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Determine the precise big-oh values for each of the
Reference No:- TGS0949865

Expected delivery within 24 Hours