cover picture cover picture


Homework 1

CMP 338: Data Structures & Algorithms
Lehman College, City University of New York
Fall 2020


This Homework Is Due By 11:55 PM on Friday September 11, 2020

Overview

In this assignment you will be implementing and testing both the Linear Search and Binary Search algorithms that we dicscussed in class.

You will also be writing a driver to test the search algorithms and you will be measuring the run times of each search.

Details

  1. TestTimes Class

    You will write the TestTimes.java class which will implement the TestTimesInterface , The interface may be downloaded from TestTimesInterface.java

    The TestTimes class will contain an array of 10 long values and a counter of how many values have been added using addTestTime(long testTime). Every time a new test time is added, the counter is incremented.

  2. LinearSearch Class

    You will write the LinearSearch.java class which will inherit from TestTimes.java and implement the Search Interface using a linear search algorithm. The interface may be downloaded from SearchInterface.java

    Please note that your search method must measure the run time and add it to the TestTimes class by using the addTestTime() method.

  3. BinarySearch Class

    You will write the BinarySearch.java class which will inherit from TestTimes.java and implement the Search Interface using a binary search algorithm. The interface may be downloaded from SearchInterface.java

    Please note that your search method must measure the run time and add it to the TestTimes class by using the addTestTime() method.

  4. Driver Class

    You will write the Driver.java class to test your implementations of:

    1. TestTimes.java
    2. LinearSearch.java
    3. BinarySearch.java

    The Driver.java will implement the Driver Interface . The interface may be downloaded from DriverInterface.java

    Please note that, in addition to implementing the DriverInterface, you are also required to write your own public static main(String[] args) method in Driver.java that tests all of your classes and methods before submitting your assignment on mimir.

Please submit the completed assignment on the Mimir Platform Website .

You must submit your .java files as a zip file of only the classes and interfaces specified above.