Sorting Algorithm Assignment
Part 1: The Selection Sort method repeatedly finds the smallest number in the current array and swaps it with the first number in the array.
Develop a pseudo-code algorithm that accomplishes this method. Include input to the method, and output from the method.
Create a Java program with input from the keyboard and output to the screen that executes this pseudo-code. Data validation standards are to be used for the input. Valid numbers are in the range of 1-1000. Invalid data should be sent to an error file with an appropriate error message.
Develop a reasonable set of 19 numbers from which to test the method. This test data should have at least one pair of numbers which are equal, two numbers that are negative, and two numbers that are higher than 1000.
Full documentation for the class and the methods is expected.
Part 2: The Bubble Sort algorithm makes several passes through the array. On each pass, successive neighboring pairs are compared. If a pair is in decreasing order, its values are swapped; otherwise, the values remain unchanged. The technique is called a bubble sort or sinking sort because the smaller values gradually "bubble" their way to the top and the larger values "sink" to the bottom.
Develop a pseudo-code algorithm that accomplishes this method. Include input to the method, and output from the method.
Create another Java program that replaces the Selection Sort with a Bubble Sort.
Test this program using the same data developed for the Selection Sort.
Document this program using class documentation standards.
Develop a new pseudo-code algorithm using an alternate loop program structure to accomplish this sort. You do not need to implement this algorithm.
Part 3: Add a counter to the inside of the nested loops in both sorts to count the number of execution of the comparison statement. Would you expect this value to be the same for both sorts? Execute both programs using the data files attached to this assignment and analyze the value of the counter for each sort. Explain your findings. If the counters are equal, what does this mean? If the counters differ, what does this mean? Based on these findings, what can you say about the two algorithms?
This assignment is an individual assignment. You are expected to do your own work in accordance with departmental Academic Honesty Guidelines. Submit the algorithm write-ups and the two compressed folder projects to Blackboard on or before the due date. Turn in the pseudo-code for each of the algorithms, source code, output of the programs, and write-ups to the instructor's office (not in his mailbox) no later than noon on Friday (5-1-2015).
Here is the following 19 numbers..
888
100
600
700
900
200
220
330
440
400
2600
-9000
0
17000
500
500
660
15
19