Computer Science I

MC140.01
Spring 2001
Assignment 8
due Wednesday 18 April 2001

The goal of this assignment is to practise sorting and searching arrays.

This assignment is worth 2% of your semester grade.

Do the following exercises from the textbook, at the end of chapter 6.

1. (7 points) 6.32 recursive selection sort

2. (7 points) 6.34 recursive linear search

3. (4 points) Include both functions in a program. The program should:
(1) declare a 20-element array inside the main() function,
(2) fill the array with random numbers,
(3) call selectionSort(), to sort the array (passing the array as an argument to the function),
(4) ask the user to enter a number to find in the array,
(5) call linearSearch() to find the user's number (passing the array as an argument to the function),
(6) print a message telling the user if her number was found, and if so, where in the array it was found, and
(7) finally, print the contents of the array, in sorted order.

4. (2 points) Make sure you do the following:

5. Submit the assignment in the usual way (i.e., follow the submission instructions from assignment #1). Also, please bring a hardcopy to class, and please staple loose sheets together!