Form groups of two or three people. You should start this group activity by introducing each member of the group. You may also want to choose one person to write down the group's discussion on the provided transparency as you go so that it can be displayed on the classroom's overhead projector.
There are three parts to this activity:
For this exercise, you can assume that your "sorting computer" knows how to:
There are many words, so you may want to start by focusing on how to sort a small subset of the words. For example, a one word list is always in sorted order. A two word list is either in sorted order, or the words' order needs to be swapped. Once you understand how the simple cases works, generalize your method to work for any number of words.
To help makes things more concrete, your group will be given a set of approximately 60 flash cards. You can physically sort them in order to help you understand how to describe the process. However, to properly simulate the computer's view of the flash cards, at most two cards should ever be "face up" at any given time. Keep in mind that your physical space is important. Where do you put things while you are working on other things? For example, think specifically about how you would explain to someone, who can hold only one thing at a time, how to swap two things.
Your group should submit its algorithm on the supplied transparency.
Since it is impractical to test every possible list of words, we choose specific kinds of lists that we think will reveal possible problems. These are called boundary cases because they focus on the edges of our algorithm where we are most likely to make an error. Note, instead of building in special steps to handle every one of these cases, you should focus on creating a single, generic procedure that will work for all cases.
To verify that your group's algorithm is correct, test it against these scenarios:
To test an algorithm using a scenario, you must simulate it as if the sorting computer were following the directions in your algorithm, not another human in your group. In other words, you have to be very careful not to use your common sense to fill in the gaps between the steps. It turns out that a human has to work very hard to be as literal, or dumb, as a computer. This process is called hand-simulation and we will continue to use this technique throughout the semester to verify our programs.
You group should write the results of the test scenarios on a separate sheet of paper. You should also describe any changes to your algorithm that were necessary.
Sorting is one of the most basic algorithms in Computer Science because it is often the difference between a fast program and a slow one. Therefore, it is common that modern sorting algorithms can sort any kind of thing that can be represented with a computer, not just words.
Once your group has created an algorithm, you should adapt it to sort new kinds of things. For example:
For each of these different kinds of objects, you should consider what changes, if any, are necessary in the commands your sorting computer understands. One way to characterize these changes is by determining what kinds of things are being modelled within your algorithm and what services, or behavior, your algorithm requires of the each different kind of thing being sorted.
You group should write the results of the change cases on a separate sheet of paper. You should also describe any changes to your algorithm that were necessary.
Comments? |