Bifalgorithm post · Computer science one · Exercises

How does a Borda-count program process ranked election ballots?

How does a Borda-count program process ranked election ballots? (Computer science one · Exercises) — "Exercise 9.10. Ranked voting elections are elections wher…

Ideas in this flowchart

  • Implement a Borda-count program for ranked voting elections.
  • In a ranked voting election, each voter ranks every candidate instead of selecting only one.
  • With n candidates, rankings range from 1 for best to n for worst.
  • The program uses a Borda count as an alternative to a Condorcet method.
  • A Condorcet method selects the candidate who wins every head-to-head majority contest.
  • For a ranking r, the candidate receives n − r + 1 points.
  • Candidates are ordered by total points, and the candidate with the highest total wins.
  • The Borda system usually produces a consensus candidate rather than a majority-preferred candidate.
  • The input file contains an ordered candidate list followed by ballot rankings.
  • The first line lists candidate names separated by commas.
  • Each later line contains comma-delimited rankings corresponding to the candidate order.
  • The program reads and processes the election file.
  • The input filename is supplied as a command-line argument, and the file is opened for processing.
  • The program reports the election results.
  • The results include each candidate's point total in candidate order and the overall winner.
  • The results also include the total number of ballots.
  • Every ballot may be assumed valid and complete, with all rankings provided.
  • The example contains five ballots and identifies Bob as the winner.
Feed/

How does a Borda-count program process ranked election ballots?

No cover

Channel

Computer science one

1 page

"Exercise 9.10. Ranked voting elections are elections where each voter ranks each candidate rather than just voting for a single candidate. If there are n candidates, then each voter will rank them 1 (best) through n (worst). Usually, the winner of such an election is determined by a Condorcet method (the candidate that would win in by a majority in all head-to-head contests). However, we’ll use an alternative method, a Borda count . In a Borda count, points are awarded to each candidate for each ballot. For every number 1 ranking, a candidate receives n points, for every 2 ranking, a candidate gets n − 1 points, and so on. For a rank of n , the candidate only receives 1 point. The candidates are then ordered by their total points and the one with the highest point count wins the election. Such a system usually leads to a “consensus” candidate rather than one preferred by a majority. Implement a Borda-count based ranked voting program. Your program will read in a file in the following format. The first line will contain an ordered list of candidates delimited by commas. Each line after that will represent a single ballot’s ranking of the candidates and will contain comma delimited integers 1 through n . The order of the rankings will correspond to the order of the candidates on the first line. Your program will take an input file name as a command line argument, open the file and process it. It will then report the results including the point total for each candidate (in order) as well as the overall winner. It will also report the total number of ballots. You may assume each ballot is valid and all rankings are provided. An example input: Alice,Bob,Charlie,Deb 2,1,4,3 3,4,2,1 4,2,3,1 3,2,1,4 3,1,4,2 An example output: Election Results Number of ballots: 5 Candidate Points Bob 15 Deb 14 Charlie 11 Alice 10\n\nWinner is Bob"

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.