Ask Question
30 June, 20:10

Suppose you are organizing a party for a large group of your friends. Your friends are pretty opinionated, though, and you don't want to invite two friends if they don't like each other. So you have asked each of your friends to give you an / enemies" list, which identi es all the other people among your friends that they dislike and for whom they know the feeling is mutual.

Your goal is to invite the largest set of friends possible such that no pair of invited friends dislike each other. To solve this problem quickly, one of your relatives (who is not one of your friends) has offered a simple greedy strategy, where you would repeatedly invite the person with the fewest number of enemies from among your friends who is not an enemy of someone you have already invited, until there is no one left who can be invited. Show that your relative's greedy algorithm may not always result in the maximum number of friends being invited to your party.

+4
Answers (1)
  1. 30 June, 21:13
    0
    Relative greedy algorithm is not optimal

    Explanation:

    Proving that Relative's greedy algorithm is not optimal.

    This can be further proved by the following example.

    Let us assumethe friends to be invited be Ali, Bill, David, Dennis, Grace, Eemi, and Sam.

    The enemy list of each friend is shown below:

    • Ali: Bill. David, Dennis

    • Bill: Ali, Grace, Eemi, Sam

    • David: Ali, Grace, Eemi, Sam

    • Dennis: Ali, Grace, Eemi, Sam

    • Grace: Bill. David, Dennis. Eemi. Sam

    • Eemi: Bill, David, Dennis, Grace, Sam

    • Sam: Bill, David, Dennis, Eemi, Grace

    From the enemy list, the one with fewer enemies is Ali.

    If we invite Ali, then Bill, David, and Dennis cannot be invited.

    Next person that can be invited is one from Grace, Eemi, and Sam

    If we choose any one of them we cannot add any other person.

    For example, if we choose Grace, all other members are enemies of Ali and Grace. So only Ali

    and Grace can only be invited.

    So we get a list of two members using relative's greedy algorithm.

    This is not the optimal solution.

    The optimal solution is a list of 3 members

    • Bill, David, and Dennis can be invited to the party.

    Hence, it is proved that relative's greedy algorithm is not optimal, where the maximum number of friends is not invited to the party.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Suppose you are organizing a party for a large group of your friends. Your friends are pretty opinionated, though, and you don't want to ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers