The following algorithm requires O (n log n )messages.Each node operates in phases and performs:
If a node is still active,it sends its unique node identifier in both directions.
In phase k,the tokens travel a distance of 2k and return back to their points of origin.
A token might not make it back to the originating node if it encounters a node with a lower unique node identifier.
A node makes it to the next phase only if it receives its tokens back from the previous round.
The node with the lowest unique node identifies is the only that will be active after log n phases.
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题
The following algorithm requires O (n log n )messages.Each node operates in phases and performs:
If a node is still active,it sends its unique node identifier in both directions.
In phase k,the tokens travel a distance of 2k and return back to their points of origin.
A token might not make it back to the originating node if it encounters a node with a lower unique node identifier.
A node makes it to the next phase only if it receives its tokens back from the previous round.
The node with the lowest unique node identifies is the only that will be active after log n phases.