Question: Wedding problem This assignment asks you to write a program in Java (or another language you choose) to find disjoint groups in a set of
This assignment asks you to write a program in Java (or another language you choose) to find disjoint groups in a set of data. Here is the story Tomorrow is Jack&Lucy's wedding day They have a lot of friends who will attend their wedding, Afterwards, they will have dinner together, so lack & tucy want to know minimum number of tables they need to setup. And you must consaider that not all the friends know each other, and friends do not want to sit with strangers One rule for this is that if I tell you A knows B, and B knows C, that means A, B, C know each other (Le., "X knows Y" is a transitive relationship), so they can sit on the sarne table. For example, if I tell you A knows B, B knows C. and D knows E, so A, B, Ccan sit on one table, and D, E must sit on another table. Therefore, this instance needs at least 2 tables. Input: Your program reads inputs from a file. The file starts with a line of two integers N and M (1c N, Mc 1000). N indicates the number of friends; the friends are marked from 1 to N. Then M lines follow. Each line consists of two integers A and B (A - B), that means friend A and friend B know each other. Output: Output how many tables they need at least. Sample Input: s 3 1 2 2 3 4 5 Sample Output: Prepare an for name of the input file and run on that input file input file in addition to your Java program. Your program should prompt the user
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
