Question: Task 4 - Who Won the Vote? A vote has been held. Each running candidate was assigned a number, and voters were instructed to write
Task Who Won the Vote?
A vote has been held. Each running candidate was assigned a number, and voters were instructed to write the number of the candidate they wished to vote for on their ballot. The election is firstpastthepost, so the candidate with the most votes wins. For example, if the ballots were then the winner is candidate # If the ballots were though, then we have a twoway tie with no clear winner. Since firstpastthepost doesn't specify how to handle ties, we will just declare situations like this a tie for now and resort to some other way of finding the winner later.
Your task is to implement the following function in winner.c using the HashTable ADT to try and find the winner given all of the ballots:
int findWinnerint ballots int numBallots;
If there is a tie, the function should return NOWINNER which is defined for you in winner.c
Testing
winner.c contains a main function which allows you to test your findWinner function. It accepts a spaceseparated list of integers as commandline arguments, which will be converted into an array that gets passed to your function. Here are some examples of its usage, and some expected outputs:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
