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.

Respuesta :

Answer:

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.

The Greedy algorithm is not optimal for this case because it cannot invite all the friends.

What is Greedy Algorithm?

This refers to a modest approach that is taken to solve a problem by selecting the best option available to solve optimization problems.

Hence, we can see that if we use the greedy algorithm, we would have to make optimal selections to get the complete optimal system, and in this case, it is not optimal.

This is because, the optimal solution is a list of 3 members, and not all the friends can be invited.

Read more about greedy algorithm here:
https://brainly.com/question/13197481

ACCESS MORE