Project #40440 - Data Structures in Java hwk

This homework has two parts, a written section, and a programming section.

Written

For the written section of this assignment, you type up your answers and submit a computer document to us. You can submit MS Word doc files, pdf files, or txt files.

1. Weiss, Exercise 2.1

2. Weiss, Exercise 2.6

3. Weiss, Exercise 2.7 - note that part b of this problem is actually part of the programming assignment. Place your answers to part a, and part c in the written solutions.

4. Weiss, Exercise 2.10 (part a)

5. Weiss, Exercise 2.11

6. Weiss, Exercise 2.15

Programming

1. Weiss, Exercise 1.15. For this problem you are creating a Rectangle class as described in the problem. You are then going to create two implementations of Comparator on that Rectangle class: one that compares by area, one that compares by perimeter. You will then create a final class called Problem1 that contains the findMax and main methods.

2. Weiss Exercise 2.7, part b. Have your main method test the run times for various values of N. Report your results in the written part of the assignment. You may find the following code useful for timing:

```public class TimeInterval {
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;
}

public double getElapsedTime() {
return (double) elapsedTime / 1000.0;
}

}

```
3. Implement a recursive binary search method. Create a class called Problem3 that takes in a .txt file with a pre-sorted array and prompts the user to enter a number to search for from stdin. Problem3 should print whether the number was found and, if the number was found, the index of the found element. Don't worry about multiple instances of an integer (just return one of the indexes).

```array.txt

0
2
4
6
8
10

\$ java Problem3 array.txt

Please enter the search key: [user enters 6]

6 is found at index 3

\$ java Problem3 array.txt

Please enter the search key: [user enters 3]

What you need to submit:

only submit the source java files, the README.txt and written.txt.

Once all the files are in place, make a zip file out of that directory. Make a copy of the zip file and then unpack it to confirm that the files are actually there.

 Subject Computer Due By (Pacific Time) 09/21/2014 05:00 pm
TutorRating
pallavi

Chat Now!

out of 1971 reviews
amosmm

Chat Now!

out of 766 reviews
PhyzKyd

Chat Now!

out of 1164 reviews
rajdeep77

Chat Now!

out of 721 reviews
sctys

Chat Now!

out of 1600 reviews

Chat Now!

out of 770 reviews
topnotcher

Chat Now!

out of 766 reviews
XXXIAO

Chat Now!

out of 680 reviews