Suppose we have N people, and there may be a group of celebrities inside.
Every person knows every celebrity, and every celebrity knows only every other celebrity.
If you are given a function know x ythat returns true or false, define a group of celebrities.
This problem is to identify a group of celebrities , and it does not identify a single celebrity among people, such as http://www.geeksforgeeks.org/the-celebrity-problem/ .
Using brute force is easy. I can build all possible subsequences of N people and filter them with a condition (everyone knows that every celebrity and every celebrity knows only another celebrity).
I also know that there should be only one group of celebrities or not.
Evidence:
Suppose we have two celebrity groups, C1 and C2. Because everyone knows ci from C1, so every cj from C2 also knows ci; symmetrically, every ci knows cj; Thus, C1 and C2 actually belong to the same group. Thus, we have no more than one group of celebrities or not.
Any ideas on a possible linear algorithm ?
change
There may be a group of celebrities, and they may not be.
source
share