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?
Part 3. MySorter Class
1. Create a new class, MySorter.
2. Copy the quicksort, merge sort and insertion
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?
![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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffb004d66-82e6-4979-bc69-f63b9509e9bc%2F196db2eb-4792-48db-b39b-e25e795448ec%2F9fpc76l_processed.png&w=3840&q=75)
![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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffb004d66-82e6-4979-bc69-f63b9509e9bc%2F196db2eb-4792-48db-b39b-e25e795448ec%2F12a0ruq_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)