Question
This program will compare two sorting methods, selection sort and the bubble sort. The assignment is to generate a 1000 character array using a random
This program will compare two sorting methods, selection sort and the bubble sort. The assignment is to generate a 1000 character array using a random generation method. Copy the random character array into another character array so that the sorting algorithms can be compared against the same array. (you should have two identical randomly generated character arrays.) Sort the first array using the selection sort method, counting the number of swaps (data exchanges) and comparisons used during the sorting process. Sort the second array using the bubble sort method, again counting the number of swaps and comparisons. The printed output should include the originally generated unsorted array, followed by each sorted array, swap count, and comparison count. The arrays should be labeled and printed nicely, with spaces between each element and a reasonable number of elements on each line. Experiment with changing the size of the arrays. You might want to use a constant for MAX_SIZE so that changing the array size is easier. After finishing the program, prepare a short lab write up explaining your findings. Which sorting method seemed better? Did changing the size of the array effect the performance of the sorting method? Turn in: source code output file short results write up Bonus: 10% We discussed the technique of inserting values into an ordered list. (figuring where to insert, shifting the remaining values down one place, etc.) We also said that an array can be filled using the insertion algorithm. This method (sometimes called insertion sort) will fill the array and sort them at the same time. Implement this algorithm by inserting the values from the original unsorted array into a new ordered array using the insert algorithm. You will have to do the insertion sort before the selection sort on the first array. Keep track of swaps and compares as you did with the other algorithms. Include your results in your output and write up.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started