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

  Define inventory program assignment from java class

This is part 6 of the inventory program assignment from Java class IT 215 from UOP and all the codes are written well and includes everything all the functionality from the previous parts and there's absolutely no errors.

  Describe how an eavesdropped can gain access

Describe how an eavesdropped can gain access to the remote server with a relatively modest number of guesses ( Hint:  The eavesdropped starts guessing after the original user has typed all but one character of the password.

  Write and run a java program

Write and run a Java program which allows the user to input two doubles and outputs the greater of the two?

  Replace the submit button

Replace the submit button (type="submit")with a regular button (type="button").  Once the buttonis clicked, display the user inputs in an HTML table below the form, if validations are successful

  Write a small java application to read the file

Write a small Java program that uses the information you gained in part (a) to read the data in the database and print it to an output text file called accounts.txt

  A client or server prepare to use udp in a java application

How does a client or server prepare to use UDP in a Java application? Are there any differences in what the client does and what the server does?

  Multiplexors whose control bit allows you

Design a 4-bit up/down counter that has 2 to 1 multiplexors whose control bit allows you to select between one of two counting modes up or down

  Create a 2-by-3 two-dimensional array of integers

Create a 2-by-3 two-dimensional array of integers and fill it with data. Loop through the array and locate the smallest value stored.

  A uml activity diagram that illustrates how program works

Create a UML activity diagram that illustrates how your program works. Your diagram must include all the data items in your program.

  Need a console program

Need a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed).

  Write a java program that reads a five-line address

Write a Java program that reads a five-line address from an input file and produces an output file with the address repeated 50 times in three columns.

  What are the main differences between java programming

question 1 what are the major differences between java programming language and any other language? list and discuss

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