Sorting and 2d Arrays – Geometry – Problem #1
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
There are people out of which any two people are either friends or strangers. A friendship group is a set of people such that any two people in that set are friends. In this problem you will find a largest friendship group. Take n as input from the keyboard. Assume that n is a positive integer at most 10 . The n people will be indexed as 1,...,n. Also ask the user for the total number of pairs of people who are friends. We will denote that number by m. The user then enters the m pairs of people who are friends. This information is to be stored in a 2D binary (integer) array A . As there are at most 10 people, the size of A will be 10x10.A[i-1][j-1] and A[j-1][i-1]should be 1 if i and j are friends and 0 otherwise. Compute and print the people who are part of a largest friendship group. Also print its size. In addition to A , you may use extra 1D arrays.