These are the instructions from the in class exercise in NotesSeptember14:

## Ground Rules

Left and right are absolute; don't get confused by someone who turns around or this won't work. (Everyone should face in the same direction....

The person with the instruction sheet makes the comparison, i.e., if the criterion is taller than the comparison is true if the person with the instruction sheet is taller than the other person.

## Bubble Sort

• Everyone starts out standing. Instructions are handed to the rightmost person in line.

0. When you are handed these instructions, start here.

1. If you are the leftmost standing person in your line,

1. If you are also the rightmost person, sit down and let me know that you're done.
2. Otherwise, give these instructions to the rightmost person -- who should be standing! -- then return to your place and sit down.

2. Otherwise, there is someone to your left. Compare yourselves.

3. If your rating is higher, switch places, then go back to the top of these instructions (step 0 or 1, take your pick).

4. Otherwise, give these instructions to the person to your left.

## Insertion Sort

• Everyone starts seated. Instructions are handed to the rightmost person in line.

0. When you are handed these instructions, start here.

1. Stand up.

2. If there is no one standing to your right,

1. If there is no one remaining seated in your line, tell everyone in your line to sit down, then let me know that you are done.
2. Otherwise, leave your spot temporarily to walk left, hand these instructions to the rightmost (closest) seated person in the line, then return to your spot and remain standing.

3. Otherwise, compare yourself to the person on your right.

1. If your rating is higher, switch places, then go back to step 2.
2. Otherwise, if there is no one remaining seated in your line, tell everyone in your line to sit down, then let me know that you are done.
3. Otherwise, leave your spot temporarily to walk left, hand these instructions to the rightmost (closest) seated person in the line, then return to your spot and remain standing.

## Selection Sort

• Everyone starts out standing. Instructions are handed to the rightmost person in line.

0. When you are handed these instructions, start here.

1. If there is no one remaining to the left,

1. If there is no one standing to the right, sit down and let me know that you are done.
2. Otherwise, approach the rightmost (furthest away) standing person.
1. Tell that person to take the empty position that you vacated.
2. Take that person's position in line.
3. Sit down.
4. Hand these instructions to the (standing) person immediately to the left.

2. Otherwise, move one position to the left. (This place should be occupied.) Compare yourself to the person in this place.