CS 122 - Computer Science II
Assignment 1
Selection and Bubble Sorts
Assignment 1

Write a program to sort an array of integer values. Your program should prompt for and input the number of values to be sorted. The program should then use the random number generator to generate that many random values in the range of 1 to 1000 and store them in an array. CAUTION: Make sure that you use a variable with the number of values to be sorted rather than using the size of the array when performing the sort. Sort the array into descending order (largest to smallest). Your program should have two sort procedues: one for a selection sort and the other for a bubble sort. Ask the user which sort to use. Print the list of numbers before and after it has been sorted as a two column printout

Hand in a copy of the program and a sample execution showing the bubble sort results.

SAMPLE EXECUTION:

HOW MANY VALUES DO YOU WANT TO SORT? 7
WHAT SORT DO YOU WANT TO USE (S=SELECTION, B=BUBBLE) ? S

235 12
982 67
543 145
587 235
12 543
145 587
67 982