Consistent Cut Check

medium · distributed-systems, clocks, ordering, causality

Consistent Cut Check

A global cut is consistent if it does not include an event without all of its causal predecessors.

You are given:

  • cuts[i]: number of events from process i included in the cut.
  • clocks[i]: vector clock of the last included event at process i.

The cut is consistent iff for all processes i and j: clocks[i][j] <= cuts[j].

Missing vector clock entries are treated as 0.

Return true if the cut is consistent, otherwise false.

Function signature

func IsConsistentCut(cuts []int, clocks [][]int) bool

Example

cuts   = [1,0]
clocks = [[1,1], []]
output = false

The event on process 0 depends on an event from process 1 that is not included in the cut.

Constraints

  • 0 <= len(cuts) <= 100000
  • len(clocks) == len(cuts)
  • 0 <= cuts[i] <= 1_000_000
  • 0 <= clocks[i][j] <= 1_000_000

Notes

  • If cuts[i] == 0, clocks[i] may be empty or all zeros.
Run tests to see results
No issues detected