About java program

Assignment Help JAVA Programming
Reference no: EM13840341

2.1 Prove by induction
Prove by induction that for all n greater than or equal to 1:

∑_(i=1)^n i 3=∑_(i=1)^n i

Hints:

• Start with n I as the base case and then the inductive step

• You already know what I + 2 + + n is for any n (discussed in class), and you should use this fact in your proof.

• You will also need to do a little bit of algebra manipulations

2.2. Function Growth Rates Order the following functions from slowest growth rate to fastest growth rate. If any of the functions grow at

the same rate, make sure to indicate this.

• n2

• n log (n)

• 2/n

• log2 (n)

• 2^

• sqrt (n)

• 86

• n2 log (n)

• n 1.5

c. TI(n) + T2(n) is 0(f(n))

d. TI(n) is O(T2(n))

2.4. Running Times (50 points total, 10 points for each program fragment) For each of the following program fragments, do the following:

a) Give an asymptotic analysis of the running time using big-O.

b) Implement the code in Java, and give the actual running times for several (at least five) values of n, to understand the running time as a function of n (e.g., is the running time linear in n).

c) Compare your analysis with the actual running time.

1. sum = 0;

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

{

sum++;

}

2. sum = 0;

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

{

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

{

sum++;

}

}

3. SUM = 0;

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

(

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

SUM++;

a. SUM = 0;

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

{

for (j = 0; j < n • n; 7++)

(

sum++;

5. sum e 0;

for (i e 0; i < n; i++)

(

for (j e 0; j < j++)

if (j t i - 0)

(

for (k e 0; k < j; k++)

sun++;

1 1

For part b), you will use large values of n to get meaningful experimental results. To get the tonal running time, I have written a class

Timelnterval, where the library functions are called. You may use the code below to get the actual running time of your program.

// Timelnterval. Java

Public class Timelnterval

{

private long startTime, endTime;

private long elapsedTime;

// Time Interval in milliseconds

public void startTiming()

{

elapsedTime = 0;

startTime = System.currentTimeMillis();

public void endTiming() endTime = System.currentTimeMillis();

elapsedTime = endTime - startTime;

// return the time in seconds between the start and the end public double getElapsedTime()

{

return (double) elapsedTime / 1000.0;

// in main method Timelnterval t = new Timelnterval();

t.startTiming(); // start the watch

// run your loop t.endTiming();

// stop the watch

// t.getElapsedTime()

returns the time interval in seconds System.out.println("Running time: " + t.getnapitedTime());

Reference no: EM13840341

Questions Cloud

Design a new class c non-routable network : Design a new Class C non-routable network
Consumer incomes increase-demand for product : If consumer incomes increase, the demand for product Y:
How is unemployment calculated in other countries : Explain how the United States calculates unemployment and why many economist do not find this as a real economic indicator. How is unemployment calculated in other countries? Give two examples. What are your thoughts and ideas on this?
Welfare effects of per unit tax : Solve for the change in consumer surplus, the change in producer surplus, the change in government revenue and change in total surplus (i.e. the deadweight loss) from the market without the tax.
About java program : java program
Game theory relate to competitive advantage : Explain game theory and how you can apply the concepts in your life and work now and in the future? How does game theory relate to competitive advantage?
State the implementation of systems and new technologies : With the implementation of systems, new technologies, and new corporate strategies, individuals will work as part of a team and will work with many varying personalities and levels of work ethic.
Explain the practical effect of price controls on product : Explain the practical effect of price controls on product and service availability, quality and true cost. What is the full impact of rent controls? On whose behalf are they imposed? Who are the winners and who are the losers? What is the impact of p..
What factors in the marketing environment present : 1. What factors in the marketing environment present opportunities or threats to automakers (AACSB: communication; reflevtive thinking)  2. Will it be possible for a startup automaker such as V-Vehicle to compete with big automakers such as Ford, GM,..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Prepare a new object of type airconditioner

Prepare a new object of type AirConditioner using the office_a_c reference variable - turn the air conditioner on using the reference to the new object.

  Packer logo method

Being a super Packer fan's wife, this assignment involves the use of the Green Bay Packer logo. Any die-hard Minnesota fans are welcome to use the Viking's logo instead.

  Provide java code to create and initialize an array

Provide Java code to create and initialize an array of integers (Java primitive int), floats or any other Java primitive type of your choice. You pick the array name and length.

  Write a program called product1ton

Write a program called Product1ToN to compute the product of integers 1 to 10 (i.e., 1×2×3×...×10). Try computing the product from 1 to 11, 1 to 12, 1 to 13 and 1 to 14.

  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.

  Using netbeans, use repetition to display a table of values

Using Netbeans, use repetition to display a table of values showing x, the square of x and the cube of x. X is to go up to 5.

  Write java program to read in sequence of hourly temperature

Write down Java program which reads in sequence of hourly temperature readings over 24-hour period using arrays. Your program must find and show maximum and minimum temperatures.

  Write a recursive method called maxsum

write a recrusive method called maxSum that accepts a list of integers. L, and an integer limit n as parameters and use backtracking to find the maximum sum that can be generated by adding elements of L that do not exceed n.

  The frantic pipe layer game

Design the Frantic Pipe Layer game

  Write a program to register students for a college

Students have names, addresses and courses. Implement the interface class RegisterStudent. RegisterStudent has one method, public boolean register, which returns the boolean value of true or false if the student is successfully registered for the ..

  Sequence of method in vector class

Construct a Vector class implementing a number of vector operations as methods along with a testing program to verify the class is working.

  Describe creating java programs to calculate the squares

Using a while loop, write the square of all integer numbers from 0 to 10 make the program calculate the squares

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