Full teaching narration is free with Private Starter.Create free account
Back to curriculum
Computer ScienceGrade 12· U.S. National — Common Core & NGSS
Aligned to:U.S. educational frameworks

Tracing a Ranked-Choice Voting Algorithm

Students trace and compare ranked-choice vote tabulation procedures, including elimination, ballot transfer, and tie-breaking rules, to evaluate how algorithm design affects election outcomes.

Tracing a Ranked-Choice Voting Algorithm

Illustrations are auto-generated and may be placeholders. They can be refreshed to match the narration.

Full teaching narration is included free with a Private Starter account.Create free account

Ranked Ballots and Majority Rules

A ranked-choice ballot lets each voter list candidates in order of preference. A voter might rank Jordan first, Casey second, and Morgan third. During tabulation, only the highest-ranked candidate still in the contest receives that ballot’s vote. A majority means more than half of the ballots counted in a round, not merely the largest share. For example, suppose nine voters cast first-choice votes: Jordan receives four, Casey receives three, and Morgan receives two. Jordan has the most votes but lacks a majority because five votes are needed. The algorithm must therefore continue. Rankings provide information for later rounds, allowing a ballot to support another candidate if its earlier choice is eliminated. This differs from plurality voting, in which Jordan would win immediately with four votes.

A ranked ballot beside a nine-vote tally shows Jordan leading without reaching the five-vote majority.
A ranked ballot beside a nine-vote tally shows Jordan leading without reaching the five-vote majority.Source: Illustrated for this lesson

Tabulation Algorithm Pseudocode

Pseudocode states the tabulation procedure precisely without requiring a particular programming language. A basic instant-runoff algorithm follows this cycle: count each active ballot for its highest-ranked active candidate; calculate the majority threshold; declare a winner if one candidate exceeds half of active ballots; otherwise identify the candidate with the fewest votes, apply the stated tie-breaking rule if necessary, eliminate that candidate, and repeat. For example, nine ballots give Jordan four first choices, Casey three, and Morgan two. No one reaches five, so Morgan is eliminated. If both Morgan voters ranked Casey next, the algorithm transfers those ballots to Casey. The next count is Jordan four and Casey five, making Casey the winner. A computer simulation should also record every tally, elimination, transfer, and decision so that users can verify the result.

A flowchart cycles through counting, checking for a majority, eliminating the lowest candidate, transferring ballots, and recording the result.
A flowchart cycles through counting, checking for a majority, eliminating the lowest candidate, transferring ballots, and recording the result.Source: Illustrated for this lesson

Tracing Elimination and Vote Transfers

Tracing means recording the state of every ballot and tally after each algorithmic step. Consider nine ballots: four rank Jordan first, three rank Casey first, and two rank Morgan first and Casey second. Round one produces Jordan four, Casey three, and Morgan two. Because Morgan has the fewest votes, Morgan is eliminated. Each Morgan ballot is inspected from left to right until the next active candidate appears. Both transfer to Casey, so round two becomes Jordan four and Casey five. Casey now has a majority and wins. A trace table should show the round number, candidate totals, eliminated candidate, transfer destinations, active-ballot count, and majority threshold. This detailed record helps students locate errors such as transferring a ballot to an already eliminated candidate or incorrectly counting one ballot for two candidates in the same round.

A two-row trace table follows nine ballots from Morgan's elimination to Casey's five-vote majority.
A two-row trace table follows nine ballots from Morgan's elimination to Casey's five-vote majority.Source: Illustrated for this lesson

Handling Ties and Exhausted Ballots

A complete algorithm must define exceptional cases before counting begins. Suppose seven ballots produce first-choice totals of Avery three, Blake two, and Cameron two. Blake and Cameron are tied for last place. If Blake’s voters prefer Cameron, eliminating Blake makes Cameron the winner, but if Cameron’s voters prefer Blake, eliminating Cameron makes Blake the winner. A predetermined tie rule, such as comparing earlier-round totals, drawing lots, or using a published fixed order, therefore can affect the outcome. An exhausted ballot has no remaining active candidate because all candidates it ranked have been eliminated. For example, if six ballots begin with Avery three, Blake two, and Cameron one, and the Cameron-only ballot becomes exhausted, five active ballots remain. Under a majority-of-active-ballots rule, three votes are then sufficient. Software must implement the jurisdiction’s exact rules and report ties and exhaustion clearly.

A branching election diagram shows a last-place tie and a separate ballot becoming exhausted as the active count falls.
A branching election diagram shows a last-place tie and a separate ballot becoming exhausted as the active count falls.Source: Illustrated for this lesson

Comparing Outcomes and Civic Trade-Offs

Algorithm design should be evaluated by both numerical results and civic purposes. Using nine ballots with Jordan four, Casey three, and Morgan two, plurality voting elects Jordan because Jordan has the most first-choice votes. Under instant-runoff voting, if Morgan’s two voters rank Casey next, Casey wins five to four after Morgan is eliminated. The procedures answer different questions: plurality identifies the largest first-choice group, while instant runoff seeks a majority among ballots still active after transfers. Ranked-choice voting can reduce pressure to vote only for a perceived front-runner and can reveal backup preferences. However, it requires clear instructions, more complex tabulation, transparent tie rules, and careful treatment of exhausted ballots. Students can model alternative transfer patterns or tie rules in a spreadsheet, compare winners and participation measures, and then judge which procedure best promotes representation, majority support, transparency, simplicity, and public trust.

A side-by-side election comparison shows Jordan winning by plurality and Casey winning after an instant-runoff transfer.
A side-by-side election comparison shows Jordan winning by plurality and Casey winning after an instant-runoff transfer.Source: Illustrated for this lesson