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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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