Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are nn students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature, i.e., if A

There are nn students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature, i.e., if A is a friend of B and B is a friend of C, then A is also a friend of C.

A friend circle is a group of students who are directly or indirectly friends. Indirect friendships can require multiple levels of indirection.

Your program will take a filename as user input. Your program will print the number of friend circles found in the class.

The input file contains an nn by nn matrix containing the characters Y and N. A Y found in the ithithrow and jthjth column indicates that studentistudenti and studentjstudentj are friends; an N indicates they are not friends.

You can assume the following:

Each element of input file will be Y or N

The number of rows and columns in the input file will be equal

All students are friends with themselves (the diagonal of the matrix is filled with Ys)

If studentistudenti is friends with studentjstudentj, then studentjstudentj is friends with studenti

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

Sybase Database Administrators Handbook

Authors: Brian Hitchcock

1st Edition

0133574776, 978-0133574777

More Books

Students also viewed these Databases questions