Design and Debug a Fair Voting Algorithm
Students create, test, and improve a step-by-step algorithm for collecting classroom votes, counting results, and handling ties fairly.

Illustrations are auto-generated and may be placeholders. They can be refreshed to match the narration.
What Makes an Algorithm?
An algorithm is an ordered set of steps for completing a task or solving a problem. Each step should be clear, specific, and possible to follow. The order matters because one step may use information produced by an earlier step. For example, a class cannot announce the winning field trip before students vote and the votes are counted. A simple voting algorithm might say: list the choices, give each student one ballot, collect the ballots, count each choice, and announce the result. If the directions only say “choose a winner,” different people might use different methods. A good algorithm gives the same result when people use the same valid ballots and follow the steps correctly. Algorithms can also include decisions, such as what to do if two choices receive the same number of votes.

Set Rules for a Fair Vote
Before writing the voting algorithm, the class must agree on fairness rules. Criteria describe what the process should accomplish, such as giving every eligible student one equal vote and counting every valid ballot accurately. Constraints are limits the class must follow, such as finishing in ten minutes or using only paper ballots. The rules should also protect privacy and prevent extra votes. For example, the teacher can check each student’s name when handing out a ballot without writing the student’s name on the ballot. A ballot is valid if it marks exactly one listed choice. A blank ballot or a ballot marking two choices can be set aside as invalid. The class should discuss and approve these rules before voting so that no rule is changed to favor a choice after the results are seen.

Write the Voting Steps
Write the algorithm so another person could run the vote without guessing. Begin with preparation, continue through voting and counting, and end with a clear result. For example: first, write three book choices on the board. Second, give one unmarked ballot to each of 24 students. Third, have each student privately mark one choice and place the ballot in a box. Fourth, count the collected ballots to confirm that there are no more than 24. Fifth, sort valid ballots into three labeled piles. Sixth, count each pile twice and record the totals. Seventh, check that the valid votes plus invalid ballots equal the number collected. Finally, announce the choice with the greatest total or follow the agreed tie rule. Numbered steps and precise words such as “exactly one” help prevent misunderstandings.

Test with Sample Ballots
Testing helps the class find problems before using the algorithm in a real vote. Create sample ballots with known results, then follow every step exactly as written. Suppose 12 sample ballots are cast for three playground games. Four choose kickball, five choose tag, two choose jump rope, and one marks both tag and kickball. According to the validity rule, the ballot with two marks is invalid. The recorded totals should be kickball 4, tag 5, jump rope 2, and invalid 1. These numbers add to 12, so every collected ballot is accounted for. Tag wins with five valid votes. During the test, observers should note any step that is confusing, missing, or difficult to complete. Testing several sets of ballots, including blank ballots and close results, gives stronger evidence that the algorithm works.

Debug Errors and Tie Cases
Debugging means finding and fixing problems in an algorithm. A test might reveal that the counted totals do not match the number of collected ballots. The class should stop, recount each pile, look for ballots stuck together, and check whether an invalid ballot was forgotten. The algorithm should say what to do instead of letting counters invent a new rule. It also needs a fair tie procedure. Suppose art club and science club each receive nine votes. One solution is a runoff in which students vote again using only the tied choices. Another solution is a random method, such as drawing one tied choice from a container. A runoff reflects student preferences again but takes more time. A random draw is quick but does not gather more opinions. The class should select and approve the tie rule before seeing any results.

Compare and Improve Algorithms
Different algorithms can solve the same voting problem, so compare them using the agreed criteria and constraints. Algorithm A uses one student counter and announces the total immediately. It is fast, but a counting mistake may go unnoticed. Algorithm B uses two counters who count separately, compare totals, and recount if their numbers differ. It takes longer, but it is more accurate and easier to check. The class might improve Algorithm B by assigning a recorder, requiring the final totals to add up to all collected ballots, and keeping ballots until the result is confirmed. Students should discuss evidence from tests, listen to different viewpoints, and explain why one design better meets the goals. The best choice is not simply a favorite method; it is the algorithm that most fairly balances accuracy, privacy, equal participation, time, and available materials.

