Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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());

Java, Programming

  • Category:- Java
  • Reference No.:- M91410157
  • Price:- $90

Priced at Now at $90, Verified Solution

Have any Question?


Related Questions in Java

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Can someone please help me with the following java

can someone please help me with the following java question The input is an N by N matrix of nonnegative integers. Each individual row is a decreasing sequence from left to right. Each individual column is a decreasing s ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As