Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in JAVA (please ) please also give TIME COMPLEXITY , SPACE COMPLEXITY and LOOP OF VARIANCE Given an array of n Players, where each Player

in JAVA (please ) please also give TIME COMPLEXITY , SPACE COMPLEXITY and LOOP OF VARIANCE

"Given an array of n Players, where each Player has a preference for exactly one of three roles (Attacker, Defender, or Healer), return one of the largest possible sets of legal teams of Players and their legal role assignments. In a legal solution, each team must have either one "Defender," one "Healer," and three "Attackers" or four "Healers" and one "Attacker." In a legal solution, each player assigned to a team must be assigned to exactly 1 role, and it must be their preferred role. In a legal solution, there can be at most n/5 teams. "

Each player can fill the role of "Attacker" (a), "Defender" (d), or "Healer" (h). There will be two possible team compositions: One defender, one healer, and three attackers (dhaaa) or four healers and one attacker (hhhha).

Example instance: 6 Attackers, 2 Defenders, and 12 Healers could form the following teams:

Team 1: (dhaaa) (1 defender, 1 healer, 3 attackers)

Team 2: (dhaaa) (1 defender, 1 healer, 3 attackers)

But this would leave 10 Healers unable to form a team. We could form a larger set of teams as follows:

Team 1: (hhhha) (4 healers, 1 attacker)

Team 2: (hhhha) (4 healers, 1 attacker)

Team 3: (hhhha) (4 healers, 1 attacker)

This would still leave 2 defenders and 3 attackers without a team. We could instead choose to form this equally large set of teams:

Team 1: (hhhha) (4 healers, 1 attacker)

Team 2: (hhhha) (4 healers, 1 attacker)

Team 3: (dhaaa) (1 defender, 1 healer, 3 attackers)

Which would still leave 5 players without a team; in this case, 1 Attacker, 1 Defender, and 3 Healers. In this instance, 3 teams is the most we are able to do, even though there are enough players (20) to fill 4 teams of size 5. Their preferences simply do not allow for more than 3 teams to be formed.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Advanced Accounting

Authors: Gail Fayerman

1st Canadian Edition

9781118774113, 1118774116, 111803791X, 978-1118037911

More Books

Students also viewed these Programming questions