1,158 views
1 votes
1 votes

There are two types of professional wrestlers: “babyfaces” (“good guys”) and “heels” (“bad guys”). Between any pair of professional wrestlers, there may or may not be a rivalry. Suppose we have n professional wrestlers and we have a list of r pairs of wrestlers for which there are rivalries. Give an $O(n+r)$ time algorithm that determines whether it is possible to designate some of the wrestlers as babyfaces and the remainder as heels such that each rivalry is between a babyface and a heel. If it is possible to perform such a designation, your algorithm should produce it.

1 Answer

1 votes
1 votes
check whether the graph is bipartite or not if it is then we can always assign one side as good guys and other side as bad guys

Related questions

0 votes
0 votes
1 answer
3
akash.dinkar12 asked Apr 7, 2019
1,235 views
Give an adjacency-list representation for a complete binary tree on $7$ vertices. Give an equivalent adjacency-matrix representation. Assume that vertices are numbered fr...