Computer Science 105 Assignment 4 - Searching and Sorting Algorithms
Due: 2:30pm October 1, 2003

Objectives and Overview: Some of the most important algorithms used in computing are in the category "search and sort."  These are useful in a variety of settings, such as web search, alphabetic sorting of a list of names, etc.  They are also related, since the most efficient search algorithms occur on lists that are sorted.   This lab provides an opportunity to explore the functioning of search and sort algorithms, as well as their efficiency.  The readings and problems for this assignment are in Chapter 3 of your text.

Part 1 - Access the Course Software

Following the same steps that you used for Assignment 2, locate the icon Invitation (OSX) that appears in the folder Invitation on your desktopand activate this familiar application:

The buttons Search Animator, Sort Animator and Sort Timer can be used for this assignment.  When you select these, you will be able to animate the behavior of many of the algorithms in Chapter 3, as well as empirically measure the efficiency of different sorting algorithms on different amounts of data.

For example, select Algorithm -> Selection Sort in the Sort Animator and then select the Run button.  You may Reset and Rerun this exercise several times to get a feeling for how the selection sort algorithm works. 

To count the number of exchanges and comparisons in a particular selection sort, you can repeatedly click the Step button and keep track of the number of times steps 9 and 6 are repeated, respectively.

Now open the Sort Timer and select Algorithm -> Selection Sort and Points -> 128, and then select Run.  Note that this gives the running time for selection-sorting 128 data points, and it graphically displays the behavior of the data being rearranged as the algorithm proceeds.

These animators and timers will be useful for answering some of the questions below.

Part 3 - Algorithmic Problem Solving

Complete exercises 12, 17, 18, 19, 20, 22, 26, and 28 on pages 110-112 of your text.  You may do this work either by hand or with a word processor. Also, you may choose to do this part of the assignment either by yourself or in teams of two.  If you work with someone else, the team may hand in one copy of the completed exercises with both names at the top.

Part 4 - Submitting Your Work

To submit a file electronically, remember to rename it so that you are identified as the author (e.g., give it a name like asst4atucker).  Then drag the file  to the csci105 -> Drop Box folder.

Once you are finished in the lab, be sure to drag the csci105 icon to the Trash - this step disconnects you from the server and prevents someone else (who may use this iMac later in the day) from accidentally accessing files in your personal folder.

To submit a handwritten assignment, leave it in the CS105 mailbox near my office (Searles 220).

Note: Even though the lab programs for this course can be saved and submitted electronically, you should always keep a backup copy of your own work, so that if a file is lost you won't have to retype it from scratch.