i m coding a c project for an algorithm class and i really need some help! Here s the problem:
I have a set of names like this one N = (James,John,Robert,Mary,Patricia,Linda Barbara) wich are stored in an RB tree. Starting from this set of names a series of couple like those ones are formed:
(James,Mary) (James,Patricia) (John,Linda) (John,Barbara) (Robert,Linda) (Robert,Barbara)
现在,需要以能够形成一小群子的方式合并这些要素,并限制每个奶制品都得到尊重,而该群体最弱的心脏。
With the couples in the example they will form two groups (James,Mary,Patricia) and (John,Robert,Barbara,Linda).
任务是将组建的团体的最高数目以及该团体中男女人数按最高标准计算。
In this case it would be 2 2 2
I was thinking about building a graph where every name is represented by a vertex and two vertex are in an edge only if they are paired. I can then use an algorithm (like Kruskal) to find the Minimum spanning tree.Is that right?
The problem is that the graph would not be completely connected. I also need to find a way to map the names to the edges of the Graph and vice-versa. Can the edges be indexed by a string?
Every help is really appreciated :) Thanks in advice!