Question: Apply the following algorithm to the ring consisting of nodes 1 , 1 5 , 9 , 1 1 , 1 9 , 3 ,

Apply the following algorithm to the ring consisting of nodes 1,15,9,11,19,3,6,20,14,7,18,13,8,5,16,12,2,4,10 and 17. Illustrate your solution using snapshots.
The Algorithm
To run for election:
status "candidate"
maxnum 1
WHILE status = "candidate" DO
sendboth ("from", myvalue, 0, maxnum)
await both replies (but react to other messages)
IF either reply is "no" THEN status "lost"
maxnum 2*maxnum
OD
On receiving message ("from", value, num, maxnum):
IF value < myvalue THEN sendecho ("no", value)0
IF value > myvalue THEN DO
status "lost"
num num +1
IF num< maxnum THEN sendpass ("from", value, num, maxnum)
ELSE sendeecho ("ok", value)
OD
IF value = myvalue THEN status "won"
On receiving message ("no", value) or ("ok", value)
IF value =/= myvalue THEN sendpass the message
ELSE this is a reply the processor was awaiting

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!