CS 50 Homework 11 (Section 1 — Prof. Marshall)

Due by class time Tuesday, April 23

If you wish, you may work with one other person on this assignment. If you work with a partner, turn in only one copy of your code, but include both of your names in a comment at the top of each file.

  1. Programming Exercise P15.11 (page 647), with the following modifications. Implement your program as an applet that asks the user for the desired size of the random array of integers at the beginning of a run. Instead of forcing the user to click OK after each screen update, simply pause the animation briefly by calling Thread.sleep after each update. You should organize your program in a way similar to the animation examples in the class folder under Lectures/week10/animation. Name your applet program "Ssort". Files to submit: Ssort.java, Ssort.html

  2. Implement graphical animations of Bubblesort, Insertionsort, and Mergesort. Your animations should be similar to your selection sort animation. Name your programs "Bsort", "Isort", and "Msort". Files to submit: Bsort.java, Bsort.html, Isort.java, Isort.html, Msort.java, and Msort.html


EXTRA CREDIT

  1. Programming Exercises P15.7 and P15.8 (page 647). The sorting algorithm is described in Review Exercise R15.13 on page 646. To measure the performance of your algorithm, implement a test program similar to TestMergesort2.java, as shown in class. Is this an efficient sorting algorithm? Name your program "Extrasort". Files to submit: Extrasort.java, TestExtrasort.java

  2. Implement a graphical animation of your Extrasort algorithm. Files to submit: Extrasort.java, Extrasort.html

Turning in Your Homework

To turn in your homework, put the specified files into a single folder named Your Name HW 11 and drop this folder into the drop box. If you work with a partner, put both of your names on the folder. If you are an off-campus student, you may copy your folder to a CLEAN floppy disk (one containing no other files or folders), and hand this in at the beginning of class, instead of using the drop box.