Classify wrestlers (check if a graph is bipartite). There are two types of profe
ID: 3802971 • Letter: C
Question
Classify wrestlers (check if a graph is bipartite).
There are two types of professional wrestlers: "baby faces" ("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.Explanation / Answer
Algorithm:
Step1: Start.
Step2: input n and r.
Step3:read names of the wrestlers w[] and rivalry pairs r[]
Step4:
while(n+r)
{
If w[1] in r[]
Put w[1] in heels;
Else in face;
N--
}
Step 5:make a match between wrestler from heels & baby face.
Step6:stop.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.