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

  A program that reads in two integers typed on the keyboard

Write a program that reads in two integers typed on the keyboard and outputs their sum, difference, and product. Must compile correctly in Eclipse. Here is what I have done, but its wrong.

  Demonstrate how the quicksort algorithm behaves

Demonstrate how the quicksort algorithm behaves. You will be implementing quicksort, but in a way that allows the program's user to visually observe how the algorithm proceeds by watching animated colored bars.

  Write java programming to show number of credits for course

Write the java programming to solve following problem. We are given a student's marks in Calculus 1, CS1, and Physics 1 (each mark being between 0 and 100) also number of credits for each course.

  Add event handling to the button find out the value the

make a windows program in java that has a labeled text field for the price of a meal. there are different discounts for

  Create a japplet

Create a JApplet that contains a JLabel and JButton. You'll create a JButton that will automatically change font typeface, style, and size when clicked by the user.

  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.

  Rock-paper-scissors :- java problem

Design decision marks are based on how you implemented our programs/classes.

  Write a void function this passed three integers

1. Write a void function this passed three integers by reference. The function should rearrange the parameter values so that the first parameter will get the smallest value; the second parameter the middle value; and the third parameter the largest v..

  Write the code and output result1 real cash register can

write the code and output result.1. real cash register can handle both bills and coins. design a single class that

  Define two different physical representations for strings

Define an ADT for character strings. Your ADT should consist of typical functions that can be performed on strings, with each function defined in terms of its input and output. Then define two different physical representations for strings.

  Modify the scholarship application

Modify the Scholarship application so that if a user enters a grade point average under 0 or over 4.0, or a negative value for either of the activities, an error message appears.

  Design a small wbis using elements from the disciplines

Design a small WBIS using elements from the disciplines of web design, database design, software engineering and object modelling;be able to develop a small WBIS using HTML forms, Java Servlets and cookies.

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