In the logic circuit, gates P and Q are hidden. S labels the wire from the output of gate P. This table shows the values at S and the output X for every combination of inputs:
A B S X
0 0 0 1
0 1 1 0
1 0 1 1
1 1 0 1
Identify gate P and gate Q, explaining how you used the table.
Model answer
P is XOR, because its output S is 0, 1, 1, 0: it is 1 only when A and B are different.
Q is NAND. Its inputs are S and B. The pairs (S, B) in the four rows are (0, 0), (1, 1), (1, 0) and (0, 1), giving X = 1, 0, 1, 1. X is 0 only when both of Q's inputs are 1, which is NAND.
Explanation
Identify each gate from its own inputs and output. Gate P's inputs are A and B, but gate Q's inputs are S and B, so you must read the S and B columns, not A and B, to build Q's truth table.