Assignment # 01
Assignment # 01
mathematics:
The algorithm you're referring to is known as the "Celebrity Problem" in graph
theory. It involves identifying a special individual within a group who is known by
everyone but knows no one. The problem can be modeled using a directed graph,
where each person is represented by a vertex and there is an edge from person A to
person B if A knows B. The celebrity is then the vertex with an indegree of n-1
(everyone knows the celebrity) and an outdegree of 0 (the celebrity knows no one).
Here's an efficient algorithm to find the celebrity using graph theory:
This algorithm has a time complexity of O(n), where n is the number of people in the
group. It efficiently identifies the celebrity by utilizing the indegree and outdegree
information derived from the graph representation.
CASE A
A celebrity is a person that everyone knows, but he doesn't know anyone.
CASE B
Whenever you are at a vertex X and X is not a celebrity, you can remove from the search, not
only X but all vertices that know (point to) X. None of these are celebrities either. Therefore
you only have to move to vertices that X points to.
The best one can do in this problem is O(n). Suppose that we have a Kn−1 where all edges
point in both directions and a vertex c, the celebrity, to which all the vertices in the Kn−1 point
to.
Given an algorithm A that finds C if v1∈V(Kn−1) is the vertex that makes A do the longest
search, then v1≠C. By the symmetry of the graph this vertex is indistinguishable from all
other vertices of the Kn−1. So, the algorithm gives the worst search for all vertices in the Kn−1.
With the information in the vertex v1 is not possible to detect where is C. Therefore in the
worst search for A it will move to some vertex v2 of the Kn−1. We can remove the v1 and its
edges from the graph and we are in the same situation but with a graph with a Kn−2. By
induction the worst search is O(n−1) in that graph.
Examples