Project 3 - Leader election on a ring
Write a class KingOfTheRing (and other classes as
needed) that implements the O(n log n) message complexity leader
election algorithm described in class for a bidirectional ring of
processors. The processor with maximum identity should be elected
as the leader. All the processors initiate the algorithm
simultaneously.
You are encouraged to examine the classes
ErrorFreeBoomRevised and CommunicationNetwork published in
github.
Input
The input to KingOfTheRing consists of a sequence of
integers.
The first integer is the number n of processors in the
ring.
The next n integers are the identities of the
processors.
Output
At the end of the algorithm every processor outputs the
following
The leader prints
<id>: I AM THE LEADER
and then it invokes CommunicationLink.printStatistics()
that will add its output.
Every other processor prints
<id>: The leader is <leader_id>
Where <id> stands for the id of the processor and
<leader_id> stands for the id of the leader.
YOU SHOULD NOT PRINT ANYTHING ELSE TO THE
OUTPUT.
Project 3 - Leader election on a ring Write a class KingOfTheRing (and other classes as needed) that implements the O(n
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am