Extra Credit Assignment #1

Due: Monday, April 26

You may pick and choose which extra credit exercises to implement, i.e., you do not need to do all of the exercises to receive extra credit.

1) Implement selection sort (algorithm 7.2) in your favorite language, but include code to time the sorting. Time selection sort on 1,000 elements. Predict how long selection sort should run on 10,000 and 100,000 elements. Finally, time selection sort on 10,000 and 100,000 elements and compare the results to your predictions.

2) Use the divide-and-conquer approach to write a recursive program to find the maximum sum in any contiguous sublist of a given list of n real values. Demonstrate that your program works correctly on several data sets by including the output of your program. Analyze your algorithm, and show the results using order notation.

3) Use the dynamic programming approach to write a program to find the maximum sum in any contiguous sublist of a given list of n real values. Demonstrate that your program works correctly on several data sets by including the output of your program. Analyze your algorithm, and show the results using order notation.

4) Implement the dynamic programming algorithm for the 0-1 Knapsack problem (section 4.4.3) and compare the performance of this algorithm with the Backtracking algorithm for the 0-1 Knapsack problem (algorithm 5.7) using several large instances of the problem.