0% found this document useful (0 votes)
14 views

Assignment 2

The document describes an assignment to write recursive sorting algorithms in Java to sort sample input data. Students are asked to implement selection sort, bubble sort, and insertion sort generically and also test the running time of each algorithm on input sizes of 10, 100, 1000, and 10000 elements.

Uploaded by

wishw244
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Assignment 2

The document describes an assignment to write recursive sorting algorithms in Java to sort sample input data. Students are asked to implement selection sort, bubble sort, and insertion sort generically and also test the running time of each algorithm on input sizes of 10, 100, 1000, and 10000 elements.

Uploaded by

wishw244
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

COSC2007O24W: Data Structures II

Assignment-2
Due-date: Friday, February 2, 2024 @11:59pm
Cut-off date: Sunday, February 4, 2024 @11:59pm

Objective:
The objective of this assignment is to practice and implement recursive versions of different sorting
algorithms.

Problem Specification:
Please download the SortingGenericSample before start. Write generic recursive Java pro-
grams which reads the elements from the following array and then sorts them using a selectionSort,
bubbleSort, and insertionSort algorithms.

Sample Input: Janet, Bob, Tom, Alan, Ellen, Karen, Wendy

Sample Output (Using selection sort algorithm): Alan, Bob, Ellen, Janet, Karen, Tom,
Wendy

Sample Output (Using bubble sort algorithm): Alan, Bob, Ellen, Janet, Karen, Tom,
Wendy

Sample Output (Using insertion sort algorithm): Alan, Bob, Ellen, Janet, Karen, Tom,
Wendy
After you have coded your generic recursive sorting algorithms, you need to test and see how
long your sorting algorithms takes to run for input size 10, 100, 1,000, and 10,000. Your program
should create integers and print a table like this: You can get a random list using the java class

ArraySize Selection Sort Bubble Sort Insertion Sort


10
100
1,000
10,000

Random, located in java.util.Random. To test the speed of your sorting algorithms, you should use
the System.currentTimeMillis() method, which returns a long that contains the current time (in
milliseconds). Call System.currentTimeMillis() before and after the algorithm runs, and subtract
COSC2007: Assignment-2

the two times. Please note that you will not get any credit if you do not implement
generic recursive versions of sorting algorithms with the above-mentioned criteria.

Submission Instructions:
Please note that the submitted work will be considered as your own work and you
confirm that you have not received any unauthorized assistance in preparing for or
doing this lab/assignment/examination. You confirm knowing that a mark of 0 may
be assigned for entire work.

Submit your complete Java source files (.java). Comment your program carefully so that it can
be read and understood. If your program is not properly commented you may lose marks. See
marking scheme for details.

Marking Scheme:
You will receive full credits for the working code, otherwise zero. No partial credits!

Comments in the program: 5


Complete program, no compile/logical error, and correct output: 45

©2023 Dr. Zamilur Rahman

You might also like