Sorting and 2d Arrays – Geometry – Problem #1

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: medium

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.

Back to Lab Problems
Sorting and 2d Arrays/Geometry/Problem #1

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #1

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.