All problems
Snapshot Isolation Version List
Problem
Simulate MVCC visibility over a version list.
operations contains "insert", "update", "delete", or "read"; times[i] is the transaction timestamp and values[i] the inserted or updated value. A version is visible to a read at ts when start <= ts < end, and the newest version's end is effectively infinite.
Return the list of recorded results (None for writes, the visible value or None for reads).
Hint
Writes close the previous version's end timestamp before appending a new one.
Test cases
case 1
in: [["insert","read","update","read","read"],[1,1,2,1,2],["a",0,"b",0,0]]
expected: [null,"a",null,"a","b"]
case 2
in: [["insert","delete","read","read"],[1,3,2,3],["x",0,0,0]]
expected: [null,null,"x",null]
case 3
in: [["read"],[5],[0]]
expected: [null]
case 4
in: [["insert","update","read","read"],[1,1,2,1],["a","b",0,0]]
expected: [null,null,"b","b"]
Starter codePython
def mvcc_ops(operations, times, values):
# Your code here
pass4 test cases · run your code against them in the editor