Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python Suppose there are two types of professional wrestlers: Babyfaces (good guys) and Heels (bad guys). Between any pair of professional wrestlers, there may

Using Python

Suppose 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 wrestlers and we have a list of r pairs of rivalries.

Current Pseudocode:

Rivalry(G) { for each vertex u in G.V { u.color = WHITE; } Q = {G[0]} while any of the vertex label is still white {} while (Q is not empty) { u = DEQUEUE(Q) for each v in G.Adj[u] { if (v.color == WHITE) { if (u.label == "Babyfaces") { v.label = "Heels" } else if (u.label == "Heels") { v.label = "Babyfaces" } else { v.label = "Babyfaces" } v.p = u ENQUEUE(Q,v) } else { if (u.label == v.label){ return impossible } } } } } }

Babyfaces vs Heels.

Input: Input is read in from a file specified in the command line at run time. The file contains the number of wrestlers, n, followed by their names, the number of rivalries r and rivalries listed in pairs. Note: The file only contains one list of rivalries

Output: Results are outputted to the terminal.

  • Yes, if possible followed by a list of the Babyface wrestlers and a list of the Heels .

  • No, if impossible.

  1. Sample Input file:

    5 Ace Duke Jax Biggs Stone 6 Ace Duke Ace Biggs Jax Duke Stone Biggs Stone Duke Biggs Jax

    Sample Output:

    Yes Babyfaces: Ace Jax Stone Heels: Biggs Duke

Input file:

6

Bear

Maxxx

Killer

Knight

Duke

Samson

6

Bear Samson

Bear Duke

Killer Bear

Samson Duke

Killer Duke

Maxxx Knight

Output:

Impossible

input file:

6

Bear

Maxxx

Killer

Knight

Duke

Samson

5

Bear Samson

Killer Bear

Samson Duke

Killer Duke

Maxxx Knight

Output:

Yes Possible

Babyfaces: Bear Maxx Duke

Heels: Killer Knight Samson

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions