Part 3. MySorter Class 1.    Create a new class, MySorter. 2.    Copy the quicksort, merge sort and insertion algorithms from the Sorter class to the MySorter class. 3.    Change the sorting algorithms to work with arrays of Library objects instead of ints.  Use the compareTo() method from the Library class to sort the Library objects by branch name. 4.    Create a main() method to test the sorting algorithms on short lists of Library objects.  (You can just adapt the main() method given in the Sorter class.)  Use asserts. Part 5. Driver Class 1.    The Driver class pulls all the pieces together.  It contains a working program that will read the Library objects from a file, call the quicksort method to sort an array of Library objects and report the amount of time it takes to do the sort. 2.    Run the Driver program and make sure it correctly reads data from a file, calls your quicksort method from the MySorter class and sorts the data.   3.    Enable asserts which will check to be sure your sort is working correctly. 4.    Study the Driver so you understand what it is doing. 5.    Alter the code and repeat the test to make sure merge sort and insertion sort also correctly sort a list of Library objects. Part 6.  The Experiment You may wish to change the Driver class to run multiple experiments in one go.  HOWEVER, if you choose to do that, be sure to re-populate the array before every sort.  That is, do not sort data that is already sorted.  Read from the file and put fresh Library objects into the array before every sort. other Make sure each line in the graph is a different color and/or texture. Add a legend to the chart so the viewer can tell what each line means. Write a brief report on the experiment. Address these points: What is the expected (theoretical) performance of each sort? (For example, O(N), O(N2), O(lg N), O(N lg N).) What is the actual performance of each sort as revealed by your data? Hint: Look at the curves in your graph. According to your data, which sort is best? Which is worst? What did you learn from doing this project?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 

Part 3. MySorter Class
1.    Create a new class, MySorter.
2.    Copy the quicksort, merge sort and insertion algorithms from the Sorter class to the MySorter class.
3.    Change the sorting algorithms to work with arrays of Library objects instead of ints.  Use the compareTo() method from the Library class to sort the Library objects by branch name.
4.    Create a main() method to test the sorting algorithms on short lists of Library objects.  (You can just adapt the main() method given in the Sorter class.)  Use asserts.

Part 5. Driver Class
1.    The Driver class pulls all the pieces together.  It contains a working program that will read the Library objects from a file, call the quicksort method to sort an array of Library objects and report the amount of time it takes to do the sort.
2.    Run the Driver program and make sure it correctly reads data from a file, calls your quicksort method from the MySorter class and sorts the data.  
3.    Enable asserts which will check to be sure your sort is working correctly.
4.    Study the Driver so you understand what it is doing.
5.    Alter the code and repeat the test to make sure merge sort and insertion sort also correctly sort a list of Library objects.

Part 6.  The Experiment
You may wish to change the Driver class to run multiple experiments in one go.  HOWEVER, if you choose to do that, be sure to re-populate the array before every sort.  That is, do not sort data that is already sorted.  Read from the file and put fresh Library objects into the array before every sort.

other

  • Make sure each line in the graph is a different color and/or texture.
  • Add a legend to the chart so the viewer can tell what each line means.

Write a brief report on the experiment. Address these points:

  1. What is the expected (theoretical) performance of each sort? (For example, O(N), O(N2), O(lg N), O(N lg N).)
  2. What is the actual performance of each sort as revealed by your data? Hint: Look at the curves in your graph.
  3. According to your data, which sort is best? Which is worst?
  4. What did you learn from doing this project?
4. The equals() method must compare the branch names and only the branch names. The
comparison must be case insensitive.
5. Be sure to test the equals() and compareTo() methods before proceeding.
Library
state: String
branch: String
city: String
zip: String
county: String
int squareFeet: int
int hoursOpen: int
- int weeksOpen: int
+ Library(state: String, branch: String, city: String, zip: String,
county: String, squareFeet: int, hoursOpen: int, weeks0pen: int)
+ getState(): String
+ getBranch(): String
+ getcity(): String
+ getZip(): String
+ getCounty (): String
+ getSquareFeet(): int
+ getHoursOpen(): int
+ getweeksOpen(): int
+ setState(state: String): void
+ setBranch (branch: String):void
+ setcity(city: String):void
+ setzip(zip: String):void
+ setCounty(count: : String):void
+ setSquareFeet(sqfeet: int): void
+ setHoursOpen (hrsOpen: int): void
+ setweeksOpen (weeksOpen: int): void
+ equals (Object obj): boolean
+ compareTo(Library): int
+ tostring(): String
Part 3. MySorter Class
1. Create a new class, MySorter.
2. Copy the quicksort, merge sort and insertion algorithms from the Sorter class to the MySorter
class.
3. Change the sorting algorithms to work with arrays of Library objects instead of ints. Use the
compareTo() method from the Library class to sort the Library objects by branch name.
4. Create a main() method to test the sorting algorithms on short lists of Library objects. (You can
just adapt the main() method given in the Sorter class.) Use asserts.
Transcribed Image Text:4. The equals() method must compare the branch names and only the branch names. The comparison must be case insensitive. 5. Be sure to test the equals() and compareTo() methods before proceeding. Library state: String branch: String city: String zip: String county: String int squareFeet: int int hoursOpen: int - int weeksOpen: int + Library(state: String, branch: String, city: String, zip: String, county: String, squareFeet: int, hoursOpen: int, weeks0pen: int) + getState(): String + getBranch(): String + getcity(): String + getZip(): String + getCounty (): String + getSquareFeet(): int + getHoursOpen(): int + getweeksOpen(): int + setState(state: String): void + setBranch (branch: String):void + setcity(city: String):void + setzip(zip: String):void + setCounty(count: : String):void + setSquareFeet(sqfeet: int): void + setHoursOpen (hrsOpen: int): void + setweeksOpen (weeksOpen: int): void + equals (Object obj): boolean + compareTo(Library): int + tostring(): String Part 3. MySorter Class 1. Create a new class, MySorter. 2. Copy the quicksort, merge sort and insertion algorithms from the Sorter class to the MySorter class. 3. Change the sorting algorithms to work with arrays of Library objects instead of ints. Use the compareTo() method from the Library class to sort the Library objects by branch name. 4. Create a main() method to test the sorting algorithms on short lists of Library objects. (You can just adapt the main() method given in the Sorter class.) Use asserts.
Objectives
Practice modifying existing code.
Compare the performance of the quick sort, merge sort and insertion sort algorithms.
Problem Description
In this assignment you will be modifying several classes that will be given to you.
In addition, you will perform an experiment to run three different sorts and collect the amount of time it
takes for each one to sort lists of varying lengths. Using this data, you will compare the performance of
the sorts.
This is a multi-part project. For best results, implement the parts in the order given below.
Part 1. Sorter
1. Download the Program 4 Starter Kit from D2L, create a new Java Project in Eclipse and import
this zip file into that project. Move the files around until all the .java files are in the src (default
package) folder.
2. You have been given a complete program in file Sorter.java. The Sorter class includes a working
version of quicksort which sorts a list of integers and a main() method.
Run this program and make sure it works as expected.
b. Enable asserts and run again. The program should give an assertion failure in line 68. If
it does not, you have not successfully enabled assertions.
Comment out the test assertion in line 68 and re-run the program which should now run
to completion successfully.
а.
С.
3. Add methods for merge sort and insertion sort to the Sorter class and test them on short lists.
Assume that you will be sorting an array of ints. You may adopt any implementation of merge
sort and insertion sort from an Internet search, your textbook or the slides/code from class.
However, be sure to cite your source by giving the link, the book and page number or the slide
deck where you found the solution. You will be penalized if you do not cite your source. Add
code to the main() method to test merge sort and insertion sort. Use asserts.
Part 2. Library Class
1. Implement a class, Library, as described in the class diagram below.
2. Library must implement the Comparable interface.
3. The compareTo() method must compare the branch names and only the branch names. The
comparison must be case insensitive.
Transcribed Image Text:Objectives Practice modifying existing code. Compare the performance of the quick sort, merge sort and insertion sort algorithms. Problem Description In this assignment you will be modifying several classes that will be given to you. In addition, you will perform an experiment to run three different sorts and collect the amount of time it takes for each one to sort lists of varying lengths. Using this data, you will compare the performance of the sorts. This is a multi-part project. For best results, implement the parts in the order given below. Part 1. Sorter 1. Download the Program 4 Starter Kit from D2L, create a new Java Project in Eclipse and import this zip file into that project. Move the files around until all the .java files are in the src (default package) folder. 2. You have been given a complete program in file Sorter.java. The Sorter class includes a working version of quicksort which sorts a list of integers and a main() method. Run this program and make sure it works as expected. b. Enable asserts and run again. The program should give an assertion failure in line 68. If it does not, you have not successfully enabled assertions. Comment out the test assertion in line 68 and re-run the program which should now run to completion successfully. а. С. 3. Add methods for merge sort and insertion sort to the Sorter class and test them on short lists. Assume that you will be sorting an array of ints. You may adopt any implementation of merge sort and insertion sort from an Internet search, your textbook or the slides/code from class. However, be sure to cite your source by giving the link, the book and page number or the slide deck where you found the solution. You will be penalized if you do not cite your source. Add code to the main() method to test merge sort and insertion sort. Use asserts. Part 2. Library Class 1. Implement a class, Library, as described in the class diagram below. 2. Library must implement the Comparable interface. 3. The compareTo() method must compare the branch names and only the branch names. The comparison must be case insensitive.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY