Interactive Parallel Sorting
Line Dancing
(or the Even-Odd Transposition Sort)
Credit for this idea goes to Dr. Paul Gray, University of Northern Iowa.
In this section you will learn the basic moves of the high-low
turnaround dance.
This dance is so phenomenal! So phenomenal in fact, that there has
yet to be music of sufficient quality to accompany the moves. It
is a dance that transcends music's current capabilities. We'll
just have to make do.
To begin, grab a number. Then grab a partner and form a single line.
(Your partner will change as the dance progresses, so don't get too
attached!!)
Face your partner. If you don't have a partner (i.e., you are the
odd man out) then stand at the end of the line facing away from
the rest of the line.
Now, everyone turn 90 degrees clockwise. Those facing the front of
the room are the "highs." Those facing the back of the room are the
"lows".
Repeat this dance {
- While you will be facing different directions, the person to your right
is your partner. Turning only your head, wink at your partner. If
you can't wink, then just say, "How do you do?" and smile broadly.
- Show your partner your number.
- If the "low" person does not have the lower of the two numbers, then
exchange numbers with your partner. That is, "low's" should have the
lower of the two numbers, and "high's" should have the higher of the
two numbers. If the numbers are equal, shout a big, "Yee Haw!"
- After the exchange, each person claps twice, turns 180 degrees
around, and prepares for the next exchange.
} Until numbers are sorted!
End persons will not have partners at times. In the event that you
find yourself without a partner, shout a big, "Yaw Hee!" It's not
crucial to the dance but it does give you something to do.
Questions for discussion
- How many iterations of the dance do you have to perform until
the numbers are sorted?
What is the best case? What is the worst case? How about on the
average?
- Think about what you would need to do to implement this
algorithm. What efficiencies and inefficiencies would be present in
the implementation?
Winner's Choice
Credit for this idea goes to Dr. Paul Gray, University of Northern Iowa.
Congratulations! You have been selected at random as a final-round
prize winner in the very successful "Hog Wild Sweepstakes".
Unfortunately, the firm that was hired to oversee the integrity of the
seepstakes process was only able to provide a list of winners, but
there is no ranking of the winners.
In order to sort this out, please report to the winner's area to
receive your prize in the form of prize money. All prizes will be
awarded, and all final-round participants are guaranteed to receive
some prize money.
Prizes will be awarded as follows:
Instructions
- Report to the winner's area and form a line.
- The prize selections will be passed through this line starting
with the first person. Prizes will be listed given their suggested
retail price.
- You may retain possession of only one prize card at a given
time. When all prizes have been claimed, you will be awarded the
suggested retail price, in cash, for the prize that you have selected.
- Undesirable prize selections must be relinquished to the next
winner in the line.
End of Instructions
Good luck in claiming your prize!!
Questions for discussion
- How many messages must be exchanged until
the numbers are sorted?
What is the best case? What is the worst case? How about on the
average?
- Think about what you would need to do to implement this
algorithm. What efficiencies and inefficiencies would be present in
the implementation?
King of the Hill
This is a simple exercise in who can beat up who (figuratively!).
Have everyone in the class stand in a single line with everyone
facing forward. Each person should follow the following instructions.
Repeat these steps {
If you are taller than the person in front of
you, then (gently!) tap that person on the shoulder and say, "Excuse
me, I need to be in front of you," and then step in front that person.
} until sorted.
Questions for discussion
- How many messages must be exchanged until
the class is sorted by height?
What is the best case? What is the worst case? How about on the
average? How can you know when the algorithm is complete?
- Think about what you would need to do to implement this
algorithm. What efficiencies and inefficiencies would be present in
the implementation?
Enjoy!