CS FundamentalsVery hardProduct company interview · GATE level

T1 executes R1(A); W1(A); R1(B) and T2 executes R2(B); W2(B); R2(A). Of the 20 possible interleavings of these two transactions (including the two serial ones), how many are conflict serializable?

  1. A. 10
  2. B. 2
  3. C. 8
  4. D. 12

Correct answer: C. 8

The only conflicting pairs are W1(A) with R2(A) and R1(B) with W2(B). The schedule is equivalent to T1, T2 only if W1(A) precedes R2(A) and R1(B) precedes W2(B). The second condition forces all of T1 before W2(B), so only R2(B) is free to sit in any of 4 positions among T1's three operations: 4 schedules. By symmetry, equivalence to T2, T1 needs W2(B) before R1(B) and R2(A) before W1(A), leaving only R1(A) free: 4 more. Every other interleaving has edges in both directions. Total 8, not just the 2 serial schedules.

More DBMS and SQL questions

Exams that ask this topic