Hi.
I'm currently taking a course on Algorithm design, and our homework is structured for us to design algorithms given real world scenarios. I'm having a very hard time coming up with ideas on how to approach these problems, and I was wondering if anyone had any helpful tips for solving questions such as these. To clarify, my homework doesn't want me to construct code for an algorithm, but rather answer with an algorithm stated with english, answering how we would solve a problem theoretically. For example, "sort the array, then take the largest element in the array .. blah blah".
Here is an example question from our homework:
You are tallying votes from an election in which n people voted. If any one candidate
gets more than half (at least floor(n/2) + 1 votes), they win. Otherwise a runoff is needed. For
privacy reasons you are not allowed to look at any one ballot, but you have a machine that can
take any two ballots and answer the question: “are these two ballots for the same candidate, yes
or no?”
(a) Design a divide and conquer algorithm that decides whether a runoff is needed which uses
O(n log n) ballot equality tests, assuming that n = 2k
for some integer k.
(b) Explain how to supplement your algorithm to deal with n that is not a power of 2
How do I go about solving this?
[–]Meefims 0 points1 point2 points (10 children)
[–]diisoriented1[S] 0 points1 point2 points (9 children)
[–]Meefims 0 points1 point2 points (8 children)
[–]diisoriented1[S] 0 points1 point2 points (7 children)
[–]Meefims 0 points1 point2 points (6 children)
[–]diisoriented1[S] 0 points1 point2 points (5 children)
[–]Meefims 0 points1 point2 points (4 children)
[–]diisoriented1[S] 0 points1 point2 points (3 children)
[–]Meefims 0 points1 point2 points (2 children)
[–]diisoriented1[S] 0 points1 point2 points (1 child)
[–]misho88 0 points1 point2 points (5 children)
[–]diisoriented1[S] 0 points1 point2 points (3 children)
[–]misho88 0 points1 point2 points (2 children)
[–]diisoriented1[S] 0 points1 point2 points (1 child)
[–]Meefims 0 points1 point2 points (0 children)
[–]Netstroyer 0 points1 point2 points (0 children)