Question: (Please use C language, and solve accordingly with output) You're working for this new Social Networking Co. called Phaselook, and here's the do-or-die task that

(Please use C language, and solve accordingly with output)

You're working for this new Social Networking Co. called Phaselook, and here's the do-or-die task that your CEO Marz Burger-Cook has assigned to you. To be completed on or before midnight of 16/1/2022 .

All you need to know about Phaselook Friends.

1. If A friends B, then they are Direct Friends, or Friends of Degree 1. If C is a friend of B (but not A), then A and C are friends of Degree 2. And so on. Friendship is a reflexive relation. The relation is also transitive, and we associate a degree with the resulting "friendship", as already explained.

2. A friendship matrix A(N,N) is a !binary 2-D array wherein A(i,j) = 1 iff i and j are friends of degree 1 and 0 otherwise, 1 <= i,j <= N; NZ+

And your assignment:

You need to write a program that takes as input (redirect from test file), the following parameters: a user number S (integer > 0), a number K (integer > 0), a number N (integer > 1) and a friendship matrix A (represented as an adjacency matrix of size NxN), and prints to stdout, the number of friends of degree K that S has. User numbers are integers and implicitly start from 1. The first thee parameters are space separated in the first line, and the matrix A is provided (row-by-row) starting from the second line of the input file.

Input file structure:

S K N

A

Example input file structure:

1 2 5

0 1 0 1 1

0 0 1 0 1

0 0 0 1 1

0 0 0 0 1

0 0 0 0 0

Read as: User 1 is friends with users 2, 4 and 5. User 2 is friends with users 3 and 5. And so on.

So the question being asked in this example is: In the given instance of 5 users, how many friends of degree 2 does user 1 have?

please tell me what you need

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!