因为LCR算法的通信复杂度过高,为o(n2),所以对他进行改进,但是前提仍然是寻找UID最大的process,区别在于不再采用类似于LCR的单向的环进行顺时针或逆时针的遍历,而是在双向环中同时向两侧进行,把搜索的过程分为很多的phase,每次向左右搜索2的phase次方个process,当到头之后再返回给发送消息的节点。
message包括三元组{uid,{in|out},hop-count}
state包括:
u,uid
send+,msg
send-,msg
state,{unknown|leader}
phase,N+
每一个process的message-generation function产生下面的消息:
send send+ to process i+1
send send- to process i-1
transition function:
复杂度:
时间复杂度:O(n)
通信复杂度:O(nlogn)
message包括三元组{uid,{in|out},hop-count}
state包括:
u,uid
send+,msg
send-,msg
state,{unknown|leader}
phase,N+
每一个process的message-generation function产生下面的消息:
send send+ to process i+1
send send- to process i-1
transition function:
send+:=null
send-:=null
if msg from i-1 is(v,out,h) then
case
v>u and h>1:send+:=(v,out,h-1)
v>u and h=1:send-:=(v,out,1)
v=u:status:=leader
endcase
if msg from i+1 is(v,out,h) then
case
v>u and h>1:send+:=(v,out,h-1)
v>u and h=1:send-:=(v,out,1)
v=u:status:=leader
endcase
if msg from i-1 is (v,in,1) and v>u then
send+:=(v,in,1)
if msg from i+1 is (v,in,i) and v>u then
send-:=(v,in,1)
if msg from i-1 and i+1 are both (u,in,1) then
phase:=phase+1
send+:=(u,out,2phase)
send-:=(u,out,2phase)
复杂度:
时间复杂度:O(n)
通信复杂度:O(nlogn)