Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 18 Online
OpenStudy (anonymous):

I have collected a huge pile of ballots for an election for class president. There are three candidates for the oce. Each ballot has a box for each candidate. The voter should write a 1 in the box for his top choice and a 2 for the second. A ballot is invalid if it does not follow that rule. The winner of the election is the candidate who gets a majority (more than 50%) of number-1 votes on valid ballots. If no candidate receives a majority, then the votes for the candidate in third place are given to the candidates who were marked 2 on the respective valid ballots. The candidate with the mos

OpenStudy (anonymous):

now is the winner. If there is a tie at any point in the process, there is no winner. For example, suppose the candidates were Alice, Bob, and Chris. There are seven ballots: Alice: 1 Bob: Chris: 2 Alice: 2 Bob: 1 Chris: Alice: 3 Bob: 2 Chris: 1 Alice: 2 Bob: 1 Chris: Alice: 1 Bob: 2 Chris: Alice: Bob: 1 Chris: 2 Alice: Bob: 2 Chris: 1 The third ballot is invalid thanks to the unnecessary third-place vote for Alice, so it doesn't count. Otherwise, Alice has two rst-place votes, Bob has three, and Chris has one. While Bob has the most votes, he does not have a majority. The (valid) ballot marking Chris in rst place had Bob in second, so its vote goes to Bob. Now Alice has two votes, and Bob has four, so Bob wins. Write an algorithm (in English) to determine the winner (if any) of the election. Be as specic as possible. In particular, each step of the algorithm can consider at most one ballot at a time. (So \count all the ballots" or \nd the person with the most rst-place votes" is not a valid single step; you'll have to further break that down into other individual steps.)

OpenStudy (anonymous):

THIS IS A ALGORITHM PROBLEM FOR ANOTHER PYTHON CLASS. PLEASE HELP.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!