All problems
Causal Broadcast Deliver Check
Problem
Check whether a broadcast message can be delivered under causal order.
local_clock is the current version vector and message is [sender, vector]. A message from sender is deliverable when its vector count for sender is exactly local_clock[sender] + 1 and every other component is at most the local count, meaning all dependencies arrived first.
Return True or False.
Hint
The sender's own counter must advance by exactly one, and all other counts must already be known.
Test cases
case 1
in: [[0,0,0],[0,[1,0,0]]]
expected: true
case 2
in: [[1,0,0],[0,[1,0,0]]]
expected: false
case 3
in: [[0,0,0],[1,[0,1,0]]]
expected: true
case 4
in: [[0,0,0],[0,[2,0,0]]]
expected: false
case 5
in: [[0,1,0],[2,[0,1,1]]]
expected: true
Starter codePython
def causal_check(local_clock, message):
# Your code here
pass5 test cases · run your code against them in the editor