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

    For the programming portion of the assignment please submit only your .java files. Your code should be well commented. In addition please include a detailed README.txt file that explains how to run your code. Please make sure that you are using Java 7.

    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]
      
      3 is not found

      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
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy