0% found this document useful (0 votes)
3 views

Assignment # 01

Uploaded by

Sana Ullah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Assignment # 01

Uploaded by

Sana Ullah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

To find the algorithm of famous person using graph theory in

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:

1. Initialize two arrays:


o indegree: A counter array to store the indegree (number of incoming
edges) for each vertex.
o outdegree: A counter array to store the outdegree (number of outgoing
edges) for each vertex.

2. Traverse the given matrix:


o For each pair (i, j), where i represents the person knowing and j
represents the person being known, increment the indegree of j and the
outdegree of i.

3. Identify the celebrity:


o Iterate through the indegree and outdegree arrays.
o If a vertex has an indegree of n-1 (everyone knows the vertex) and an
outdegree of 0 (the vertex knows no one), then that vertex is the
celebrity.

4. Return the celebrity's index:


o If a celebrity is found, return its index. Otherwise, return -1, indicating
that no celebrity exists.

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.

If we think of a group of people as a graph, where if there is an arrow from A to B that


means "A knows B", then a celebrity is a vertex of the graph that everyone is pointing to
him, but he points to no one. Meaning if C is a celebrity in a group of n people:
Degin(C)=n−1, Degout(C)=0
This diagram shows it more clearly:
here C is a celebrity. Obviously there can't be more than 11 celebrity in a group
of n people, because if C is a celebrity, then he does not point to anyone, specifically he
does not point to D, so D is not a celebrity because not everyone knows him (C doesn't).
Propose an efficient algorithm, that runs in minimal steps, to find the celebrity (the star)
in a graph with n vertices.
The best solution I came up with is run through all the vertices and check if the current
vertex is a celebrity. Checking if a vertex is a celebrity can be done in Θ(1), but we run
through (potentially) all the vertices, so overall it's Θ(n) which is pretty bad.
I'm sure there is a better way, since suppose we started at vertex A and it doesn't point
to B. Then we don't need to check B now. For sure it's not a celebrity.

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

Leonhard Euler (1707-1783) is considered to be one of the founders of graph theory.


He solved the famous Königsberg Bridge Problem in 1736, which involved determining
whether it was possible to cross all seven bridges of Königsberg (now Kaliningrad) without
revisiting any of them. Euler's solution involved modeling the problem as a graph and proving
that it was impossible to find such a path.
Paul Erdős (1913-1996) was a Hungarian mathematician whő made significant
cőntributiőns tő graph theőry and őther areas őf mathematics. He is knőwn főr his wőrk őn
randőm graphs, graph cőlőring, and extremal graph theőry. Erdős published őver 1,500
papers in his lifetime, and he collaborated with hundreds of mathematicians from all over the
world.
Alfred Tarski (1901-1983) was a Polish mathematician and logician who made
significant contributions to model theory, set theory, and graph theory. He is known for his
work on decision procedures, definability, and the Banach-Tarski paradox. Tarski was a
member of the Warsaw School of Mathematics, and he was one of the most influential
mathematicians of the 20th century.

You might also like