In: Computer Science
Given an array A[0 … n-1], where each element of the array represent a vote in the election. Assume that each vote is given as an integer representing the ID of the chosen candidate. Can you determine who wins the election? What is the complexity of your solution? Hint: it is similar to finding the element that is repeated the maximum number of times.
Please find the step by step clear solutions.
I have discussed 3 ways of solving this problem for your understanding. PLEASE GIVE ME AN UPVOTE. I HAVE SPENT A LOT OF TIME TO SOLVE THIS PROBLEM TO MAKE SURE THAT YOU UNDERSTAND EVERYTHING..!
COMPARISION OF ALL THE ABOVE APPROACHES