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 4- 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 first-past-the-post, so the candidate with the most votes wins. For example, if the ballots were [1,2,1,1,3,3], then the winner is candidate #1. If the ballots were [1,2,2,1,3] though, then we have a two-way tie with no clear winner. Since first-past-the-post 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 findWinner(int *ballots, int numBallots);
If there is a tie, the function should return NO_WINNER (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 space-separated list of integers as command-line 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!