Determine the precise big-oh values

Assignment Help JAVA Programming
Reference no: EM13696577

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?

Reference no: EM13696577

Questions Cloud

Creates an object of type fahrenheit : Creates an object of type Fahrenheit and an object of type Celsius - Accepts a single argument from the command line
Should the cio or cto report to the company president : Contact at least three people at your school or a nearby company who use information systems. List the systems, the position titles of the users, and the business functions that the systems support.
Sum of all odd numbers between a and b : The sum of all odd numbers between a and b (inclusive). Where a and b are read in by the user - Can you find the error in this code.
Represent 99 and -99 in 2s complement format : what are the largest(positive) and smallest (negative) integers a word can represent - Represent 99 and -99 in 2's complement format.
Determine the precise big-oh values : Determine the precise Big-Oh values for each of the following code samples, based on the number of statement executions - Remember to consider each statement in compound statements separately.
Which algorithm should be most efficient : the test conditions are equal for both algorithms, which algorithm should be most efficient when N is arbitrarily large (i.e., you can select N to be as large as you want it to be)?
Prepare an app that calculates the product of a series : Prepare an app that calculates the product of a series of integers that are passed to method   product using a variable-length argument list.
Translate the given code into mips64 assembly language : you can use the instructions 'blt' (branch on less than), 'ble' (branch on less or equal), 'bgt' (branch on greater than) and 'bge' (branch on greater or equal) - Translate the given code into MIPS64 assembly language.
Write a statement that prints the message recall : Clunker Motors Inc. is recalling all vehicles from model years 1995-1998 and 2004-2006. Given a variable modelYear - Write a statement that prints the message "Recall" to standard output if the value of modelYear falls within those two ranges.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program to print out a simplified bill

Write a program to print out a simplified bill. The customer's name, the number of hours of labor, and the cost of parts and supplies should be entered in response to INPUT statements.

  Describe different professional levels in this discipline

What is Anesthesiology and critical care medicine describe the specific discipline, what is their focus (i.e., emergency medicine, education and prevention, psychiatric treatment etc.) Describe the different professional levels in this discipline

  Write java program to store employee id number

Use employee data file called employees.txt should comprise at least 5 employee records. Each record stores employee ID number (six digits) last name, first name, middle inital,gender(m or f).

  Information systems to strengthen customer

Which of the following illustrates the use of information systems to strengthen customer and supplier intimacy? BPM is considered concluded when the new processes are both implemented and accepted.

  Java servlet uses doget to return markup document

Write down Java servlet which uses doGet to return markup document which provides your name, e-mail address, and mailing address along with a brief autobiography.

  standard graph with four quadrant

Write a program in java that asks the user for values of x and y, and displays the point as an ordered pair along with a message that describes where that point falls on the standard graph with four quadrant.

  Including four sets of quadruplet andsevwn sets of triplets

Mrs. Bernard Scheinberg of Austria had sixty-nine children. Including four sets of quadruplet, sevwn sets of triplets, and sixten of twins. after Mrs. scheinberg died at the age of 56, her husband remarried. during his remaining years, he fathered an..

  Critics of american often that teacher''s unions represent

Which organization has proposed a set of standards for both elementary level and secondary-level teachers? According to the latest info.,  teachers will be most needed in which of the following areas: Critics of American often argue that teacher's un..

  Task 1a define and describe the steps to program

task 1a. define and describe the steps to program development.b. what is an algorithm? discuss and provide examples

  Writing a program that parses

The programming project involves writing a program that parses, using recursive descent, a GUI definition language defined in an input file and generates the GUI that it defines.

  If the number on two of the players'' four cards

If the number on two of the players' four cards is the same and the number on the remaining two cards is also the same yet the number on all four cards in not the same then the player gets their bet back and in addition wins 22 chips for each chip th..

  Write a method called add uneven arrays

Write a method called addUnevenArrays that takes two arrays, a and b, and returns a new array, c, with alength that is the maximum of the lengths of a and b. Each c[i] is the sum of the corresponding elementsof a and b if both elements exist.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd