Let P1(){ A, B } and P2(){ 1, 2 }
Now possible sequence and value of variables B, C and D are as follow -->
- A B 1 2 {3,1,4}
- A 1 B 2 {3,1,4}
- A 1 2 B {2,1,4}
- 1 A B 2 {3,1,4}
- 1 A 2 B {2,1,4}
- 1 2 A B {4,2,4}
So Number of distinct values that B can possibly take after the execution is 3 {2,3,4}.
PS: Little bit long but error free method.