About

4.3 Past Exam Question: (A AND NOT B) OR (C XOR D)

Theory: Past Exam Question: (A AND NOT B) OR (C XOR D)

The professor told the class that this question came from a past exam, so study it carefully. It combines everything from Lectures 3 and 4: a four-variable truth table, extended columns, checking a given set (with the size trap from 4.2), and finding a new minimum set with the colour path (4.1).

Past exam question. Given the expression Z=(A AND NOT B) OR (C XOR D)Z = (A \text{ AND NOT } B) \text{ OR } (C \text{ XOR } D), determine whether the following test cases satisfy MC/DC coverage. If they do not, find a minimum MC/DC test set.

Test caseABCDZ
TC1TTFFF
TC2TFFFT
TC3FTFFF
TC4FTFTT
TC5FTTFT

Step 1: Count First

There are 4 variables, A, B, C and D. So a minimum test set needs n+1=5n + 1 = 5 rows. The given set has 5 rows, so the size is OK. But remember the size trap (4.2): we must still check the pairs.

Step 2: Build the Truth Table, with Helper Columns

Four variables give 2×2×2×2=162 \times 2 \times 2 \times 2 = 16 rows, in the professor’s order (D changes every row, C every 2, B every 4, A every 8). To fill Z quickly, the professor made two helper columns, one for each part of the expression:

RowABCDA AND NOT BC XOR DZ
1FFFFFFF
2FFFTFTT
3FFTFFTT
4FFTTFFF
5FTFFFFF
6FTFTFTT
7FTTFFTT
8FTTTFFF
9TFFFTFT
10TFFTTTT
11TFTFTTT
12TFTTTFT
13TTFFFFF
14TTFTFTT
15TTTFFTT
16TTTTFFF

Step 3: Find the Given Test Cases in the Table

Match each test case to its row:

Test caseABCDZRow
TC1TTFFF13
TC2TFFFT9
TC3FTFFF5
TC4FTFTT6
TC5FTTFT7

So the given set is {5, 6, 7, 9, 13}. (Notice that the Z values given in the question agree with the table, a cheap check worth doing.)

Finding rows fast: think of T as 1 and F as 0. Then

row=8A+4B+2C+D+1.\text{row} = 8A + 4B + 2C + D + 1.

For TC1 (T, T, F, F): 8+4+0+0+1=138 + 4 + 0 + 0 + 1 = 13. This shortcut works because the professor’s row order is simply counting in binary. In the exam, still confirm the row in your table.

Step 4: Fill the Four Extended Columns

Use the usual rule: one variable varies, the other three are fixed. A partners are 8 rows apart, B partners 4 apart, C partners 2 apart, D partners are neighbours. Bold rows are the given test cases.

RowABCDZA variesB variesC variesD varies
1FFFFF932
2FFFTT41
3FFTFT14
4FFTTF1223
5FTFFF76
6FTFTT85
7FTTFT58
8FTTTF67
9TFFFT113
10TFFTT
11TFTFT
12TFTTT416
13TTFFF91514
14TTFTT1613
15TTTFT1316
16TTTTF121415

Notice how different the columns are:

Step 5: Check the Given Set

The given set is {5, 6, 7, 9, 13}. Start with column A, because it has the fewest pairs. It needs {1, 9} or {4, 12}. The set has 9, but not 1. It has neither 4 nor 12. So column A has no pair. The professor pointed out that you can see this by looking at column A alone.

For completeness: column B has {9, 13}, column C has {5, 7}, and column D has {5, 6}. Only A fails, but one failure is enough.

How to write the first answer: “No. The given test cases do not satisfy MC/DC, because there is no independence pair for condition A. Column A needs rows {1, 9} or {4, 12}, and neither pair is in the given set {5, 6, 7, 9, 13}.”

Step 6: Find a New Minimum Test Set

The question does not ask you to keep the old set, so start fresh, and follow the colour path from the column with the fewest pairs:

  1. Column A: take {1, 9}.
  2. Stand on row 9 and look at column B. It says 13. Take {9, 13}.
  3. Stand on row 13 and look at column C. It says 15. Take {13, 15}.
  4. Stay on row 13 and look at column D. It says 14. Take {13, 14}.

The new set is {1, 9, 13, 14, 15}. It has 5 rows, which is n+1n + 1, and it has a pair in every column, so it is a minimum test set. Row 13 is the hero here: it is shared by three pairs.

RowABCDZ (expected)What it proves
1FFFFFwith row 9: proves A
9TFFFTwith row 1: A; with row 13: B
13TTFFFthe shared row for B, C and D
14TTFTTwith row 13: proves D
15TTTFTwith row 13: proves C

Write the final answer as true/false values with the expected output Z, not only as row numbers: the professor reminded the class that a test case must have both the input and the expected output.

There are 16 different minimum sets for this question. You only need to give one, unless the question asks for all of them.

Exam Habits from This Class

Common mistake: seeing that the given set has exactly 5 rows and answering “Yes, it is a minimum MC/DC set”. The count only matters after every column has a whole pair, and here column A has none.


Worked Examples

Exercise 1

For Z=(A AND NOT B) OR (C XOR D)Z = (A \text{ AND NOT } B) \text{ OR } (C \text{ XOR } D), how many rows must a minimum test set have? Why?

Show solution ↓
Solution

There are n=4n = 4 variables (A, B, C, D), and a minimum MC/DC test set has n+1n + 1 rows:

n+1=4+1=5.n + 1 = 4 + 1 = 5.

So a minimum test set has 5 rows: at least one independence pair per variable, with enough overlap that four pairs fit into five rows.

Exercise 2

For the same Z, is {4, 12, 13, 14, 16} a minimum test set?

Show solution ↓
Solution

Question 1 (pairs).

  • A: {4, 12} inside ✓.
  • B: {12, 16} inside ✓.
  • C: {14, 16} inside ✓.
  • D: {13, 14} inside ✓.

Question 2 (size). 5 rows =n+1= n + 1 ✓.

Yes, it is a minimum test set. As test cases: row 4 (F,F,T,T) → F, row 12 (T,F,T,T) → T, row 13 (T,T,F,F) → F, row 14 (T,T,F,T) → T, row 16 (T,T,T,T) → F.

Exercise 3

A set has exactly n+1n + 1 rows. Does that mean it is a minimum test set?

Show solution ↓
Solution

No. First it must be a test set, with a full independence pair in every extended column. Only then does the size n+1n + 1 make it minimum.

The past exam question is an example: the given set {5, 6, 7, 9, 13} has 5 rows, exactly n+1n + 1, but column A has no pair (it needs {1, 9} or {4, 12}), so it is not an MC/DC test set at all.

Exercise 4

Use the row formula to find the row numbers of (F, T, T, F) and (T, F, T, T). Then read their Z values from the table.

Show solution ↓
Solution

With T = 1 and F = 0, row=8A+4B+2C+D+1\text{row} = 8A + 4B + 2C + D + 1.

  • (F, T, T, F): 0+4+2+0+1=0 + 4 + 2 + 0 + 1 = row 7. Z: A AND NOT B is F; C XOR D = T XOR F = T; so Z = T.
  • (T, F, T, T): 8+0+2+1+1=8 + 0 + 2 + 1 + 1 = row 12. Z: A AND NOT B = T AND T = T; so Z = T (C XOR D is F, but one true helper is enough).

Both agree with the truth table ✓.

Exercise 5

Find a different minimum test set by following the colour path from the other A pair, {4, 12}. Give the answer as test cases with expected Z.

Show solution ↓
Solution
  1. Column A: take {4, 12}.
  2. Stand on row 12, look at column B: it says 16. Take {12, 16}.
  3. Stand on row 16, look at column C: it says 14. Take {14, 16}.
  4. Stay on row 16, look at column D: it says 15. Take {15, 16}.

The set is {4, 12, 14, 15, 16}, with row 16 shared by three pairs.

RowABCDExpected Z
4FFTTF
12TFTTT
14TTFTT
15TTTFT
16TTTTF

Check: A {4, 12} ✓, B {12, 16} ✓, C {14, 16} ✓, D {15, 16} ✓, 5 rows =n+1= n + 1 ✓.

Exercise 6

For the same Z, check each set: (a) {1, 2, 9, 13, 15}; (b) {9, 13, 14, 15, 16}; (c) {1, 9, 13, 14, 15, 16}.

Show solution ↓
Solution

Start with column A each time, since it has the fewest pairs ({1, 9}, {4, 12}).

  • (a) A {1, 9} ✓, B {9, 13} ✓, C {13, 15} ✓, D {1, 2} ✓; 5 rows. Minimum test set. (Here D is proved by a pair at the top of the table, which is fine: any whole pair counts.)
  • (b) A: 9 is present but 1 is not, and neither 4 nor 12 is present. Not a test set. It has 5 rows, so this is the size trap again.
  • (c) A {1, 9} ✓, B {9, 13} ✓, C {13, 15} ✓, D {13, 14} ✓; but 6 rows. Test set, not minimum (row 16 is unnecessary).
Exercise 7

Rows 10 and 11 of the extended table have no partner in any column. Explain why, using the helper columns.

Show solution ↓
Solution

In rows 10 (T, F, F, T) and 11 (T, F, T, F), both helper columns are true: A AND NOT B is T, and C XOR D is T. Z is an OR of the two helpers, so to make Z false, both helpers would have to become false.

Changing one variable can only affect one helper: A or B touches only A AND NOT B, and C or D touches only C XOR D. The other helper stays true, so Z stays T. No single change flips Z, so these rows have no independence partner in any column. Such rows can never be part of a pair and never need to be chosen.

Exercise 8

A similar exam question: for Z=(A AND B) OR (C AND D)Z = (A \text{ AND } B) \text{ OR } (C \text{ AND } D), do the rows {6, 8, 10, 12, 14} satisfy MC/DC? If not, find a minimum MC/DC test set.

Show solution ↓
Solution

Count first. 4 variables, so a minimum set has 5 rows. The given set has 5 rows, but the pairs must still be checked.

Truth table and extended columns. Z is T when A and B are both T (rows 13–16) or C and D are both T (rows 4, 8, 12, 16).

RowABCDZA variesB variesC variesD varies
1FFFFF
2FFFTF4
3FFTFF4
4FFTTT23
5FTFFF13
6FTFTF148
7FTTFF158
8FTTTT67
9TFFFF13
10TFFTF1412
11TFTFF1512
12TFTTT1011
13TTFFT59
14TTFTT610
15TTTFT711
16TTTTT

Pairs: A {5, 13}, {6, 14}, {7, 15}; B {9, 13}, {10, 14}, {11, 15}; C {2, 4}, {6, 8}, {10, 12}; D {3, 4}, {7, 8}, {11, 12}.

Check the given set {6, 8, 10, 12, 14}. A has {6, 14} ✓, B has {10, 14} ✓, C has {6, 8} and {10, 12} ✓. But D needs {3, 4}, {7, 8} or {11, 12}: 8 is present without 7, and 12 without 11. No. The rows do not satisfy MC/DC, because condition D has no independence pair.

New minimum set (colour path). Every column has three pairs, so start anywhere, e.g. A {6, 14}. Stand on row 6: column C says 8, take {6, 8}. Stand on row 8: column D says 7, take {7, 8}. Stand on row 14: column B says 10, take {10, 14}. The set is {6, 7, 8, 10, 14}:

RowABCDExpected Z
6FTFTF
7FTTFF
8FTTTT
10TFFTF
14TTFTT

Check: A {6, 14}, B {10, 14}, C {6, 8}, D {7, 8}, and 5 rows =n+1= n + 1 ✓.