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

  Develop a graphical user interface based java program

Develop a Java program that can communicate with a real SMTP email server for sending emails. TNE 60003 - introduction to network programming, You program should provide a GUI and can successfully send the SMTP commands to the mail server

  Create a gui application with jframe

Create a GUI application with JFrame that contains five labels describing reasons that a customer might not buy a specific product (e.g. too expensive).

  Most of the companies use virtualization to make test

write a 200- to 300-word short-answer response to the following many companies use virtualization to create test

  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.

  Create an application that provides a solution

Create an application that provides a solution for problem 20.8 In addition to requirements specified in the description.

  Convert string values from keyboard to numeric values

How do we convert string values from the keyboard to numeric values? How do we create output strings containing the values from our variables and how to answer the problem? Any help would be appreciated.

  Write a generic class

Write a generic class (using Java generics) called Pair that stores two values of the generic type.  It should have a constructor to set them, two methods getfirst() and getsecond() to retrieve them.

  Create a form that contains a guessing game

Create a Form that contains a guessing game with five RadioButtons numbered 1 through 5.  Randomly choose one of the RadioButtons as the winning button.  When the user clicks a RadioButton, display a message indicating whether the user is correct.

  Cascading style sheet to a website

Compare and contrast the process of adding JavaScript and a Cascading Style Sheet to a Website. Determine if they can be used simultaneously in a page.

  Write java code to read integers from an input file

write java code to read integers from an input file and write only the odd numbers to an output file. the two file names will be provided on the command line as the input file followed by the output file.

  Develop a graphical user interface

For this assignment, you are required to develop a Graphical User Interface (GUI) Java Program to demonstrate you can use Java constructs including input/output via a GUI.

  Topics: user interface, input validation, computer security

Topics: user interface, input validation, computer security, i/o processing, storage & retrievalAssignment: Write a program that will simulate a basic registration/login process for a standard application or website.Menu ItemsCreate a profileAsk the ..

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