Program Documentation: Election Winner Determination Algorithm
Prepared For: IT SBA
Prepared By: Elroy Canchon
Date: March 18, 2025
1. Overview
This document describes an algorithm designed to determine the winning candidate in a
constituency election. The algorithm accepts as input the names of four candidates along with the
number of votes each candidate receives. The candidate with the highest vote count is declared
the winner.
2. Purpose
The purpose of this algorithm is to:
● Process the input vote data for four candidates.
● Identify and store the candidate with the most votes.
● Display the winning candidate as the successful candidate in the election.
3. Input and Output Specifications
Inputs:
● Candidate Names: Four strings representing the names of the candidates.
● Vote Counts: Four integers representing the number of votes each candidate receives.
Output:
● Winning Candidate: The name of the candidate with the highest number of votes.
Assumption:
The algorithm assumes that vote counts are non-negative integers and that there is a clear
candidate with the highest vote count. (In cases of a tie, additional tie-breaker logic might be
necessary.)
4. Algorithm Steps
The algorithm follows these steps:
1. Start:
Begin the process.
2. Input:
Read the names of the four candidates along with the number of votes each candidate
receives.
3. Determine Maximum Votes:
Compare the vote counts to find the candidate who received the most votes.
4. Store the Winner:
Save the name of the candidate with the highest vote count.
5. Display the Winner:
Output the winning candidate’s name.
6. Stop:
End the process.
5. Pseudocode
Below is the pseudocode that outlines the logic of the algorithm:
BEGIN
// Step 1: Start
PRINT "Election Winner Determination Algorithm Started"
// Step 2: Input candidate data
INPUT candidate1, votes1
INPUT candidate2, votes2
INPUT candidate3, votes3
INPUT candidate4, votes4
// Step 3: Determine the candidate with the highest votes
IF votes1 >= votes2 AND votes1 >= votes3 AND votes1 >= votes4 THEN
winner = candidate1
ELSE IF votes2 >= votes1 AND votes2 >= votes3 AND votes2 >= votes4 THEN
winner = candidate2
ELSE IF votes3 >= votes1 AND votes3 >= votes2 AND votes3 >= votes4 THEN
winner = candidate3
ELSE
winner = candidate4
ENDIF
// Step 4: Store the winner (already stored in variable "winner")
// Step 5: Display the winner
PRINT "The winning candidate is:", winner
// Step 6: Stop
PRINT "Election Winner Determination Algorithm Finished"
END
6. Implementation Considerations
● Input Validation:
Ensure that the vote counts provided are valid (non-negative integers) and that the
candidate names are not empty.
● Handling Ties:
The algorithm currently selects the candidate with the highest vote count. In the event of
a tie, you might choose to either declare a tie or add additional rules to break the tie.
● Testing:
It is recommended to test the algorithm with various datasets:
o Standard Case: One candidate clearly has the highest votes.
o Edge Case: Two or more candidates have equal vote counts.
o Invalid Inputs: Non-integer values for votes or empty candidate names.
7. Conclusion
This documentation outlines the election winner determination algorithm using the steps
detailed. The algorithm efficiently processes the vote data for four candidates, determines which
candidate has received the most votes, and outputs the winning candidate. This documentation
should assist in understanding, implementing, and potentially extending the algorithm for further
requirements.