Docsity

Wentworth Tech: Comparing Sort Algorithms - Data Structures I HW3, Assignments of Data Structures and Algorithms

Toggle sidebar
bg1
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP380 Section 71 - Data Structures I - Spring, 2007
Homework 3 – Sort Timings
Instructor: Bob Goldstein (617) 912-2512
http://home.comcast.net/~goldsteinr/Courses/index.html
http://goldstein.eri.harvard.edu/courses/index.html
http://myweb.wit.edu/goldsteinr/Courses/index.html
Due Date: February 13, 2007
Hand In: Printout of program code and dialogue of how it runs.
Purpose:
This homework is intended to compare the time it takes to run various sort algorithms. Compare three sorts:
(1) home-grown bubble sort (2) home grown selection sort and (3) built-in Java Arrays sort facility
Description:
The items that you will be sorting are the Clothing objects that you created in Homework 2. You need to
test the sort performance on arrays of length 10,100,1000, 10000, and 100000 randomly generated clothing
objects.
Here are the things you need to do to accomplish this homework:
(1) Re-write the bubble sort and the selection sort methods so that they can be used to sort arrays of
any object that implements “comparable”. Use the SortSSN example we did in class to see how to
do this.
(2) Add the compareTo() method to the Clothing class.
(3) Make a method that generates a random list of the Clothing objects
(4) Use the Timing class of Fort and Topp to time each sort.
Extra Credit:
Make a graph of the results (you can use a log-linear graph). You can use Excel to make the graphs
/app/work/qkd27z-378475-2765031-homework3-doc.doc 1 11/28/2020 11/28/2020

Partial preview of the text

Download Wentworth Tech: Comparing Sort Algorithms - Data Structures I HW3 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP380 Section 71 - Data Structures I - Spring, 2007

Homework 3 – Sort Timings

Instructor: Bob Goldstein (617) 912- [email protected] [email protected] http://home.comcast.net/~goldsteinr/Courses/index.html http://goldstein.eri.harvard.edu/courses/index.html http://myweb.wit.edu/goldsteinr/Courses/index.html Due Date: February 13, 2007 Hand In: Printout of program code and dialogue of how it runs. Purpose: This homework is intended to compare the time it takes to run various sort algorithms. Compare three sorts: (1) home-grown bubble sort (2) home grown selection sort and (3) built-in Java Arrays sort facility Description: The items that you will be sorting are the Clothing objects that you created in Homework 2. You need to test the sort performance on arrays of length 10,100,1000, 10000, and 100000 randomly generated clothing objects. Here are the things you need to do to accomplish this homework: (1) Re-write the bubble sort and the selection sort methods so that they can be used to sort arrays of any object that implements “comparable”. Use the SortSSN example we did in class to see how to do this. (2) Add the compareTo() method to the Clothing class. (3) Make a method that generates a random list of the Clothing objects (4) Use the Timing class of Fort and Topp to time each sort. Extra Credit: Make a graph of the results (you can use a log-linear graph). You can use Excel to make the graphs /app/work/qkd27z-378475-2765031-homework3-doc.doc 1 11/28/2020 11/28/