Question
There are n people. The entry K[i][j] of a rectangular n by n array K is set to 1 when person i knows person j
There are n people. The entry K[i][j] of a rectangular n by n array K is set to 1 when person i knows person j and is set to 0 otherwise. Assume that K[i][i] = 1 for every i, since everyone knows themselves. A celebrity is a person who is known by everyone and does not know anyone besides himself/herself. For example, in the left diagram below person 3 is a celebrity. This corresponds to K = { {1, 1, 1, 0}, {0, 1, 1, 0}, {0, 0, 1, 0}, {1, 0, 1, 1} }. There is no celebrity in the right diagram. This corresponds to K = { {1, 1, 0, 1}, {0, 1, 1, 0}, {1, 0, 1, 0}, {1, 0, 1, 1} }. Write and test a method that takes K as a parameter and determines which row is a celebrity or concludes that there is none.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started