GATE / CS ARCHIVE

SIMILAR QUESTIONS / DIGITAL LOGIC

Check commutativity and associativity

4 questions solved the same way, newest first. Back to Digital Logic

How these are solved

Identify the binary operation from formula/truth table, compare f(a,b) with f(b,a), and compare both three-input parenthesizations or exhibit a counterexample.

2 marks · MCQ
Report issue

Boolean Algebra & Logic Gates

Question 40, GATE 2015: Binary operator ≠ has truth table (p,q,result): (0,0,0),(0,1,1),(1,0,1),(1,1,0). Which properties hold? A commutative and associative; B commutative only; C associative only; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Recognize XOR, which is addition modulo 2. Swapping its two inputs preserves their sum modulo 2, proving commutativity. Grouping three inputs either way gives (p+q+r) mod 2, proving associativity. A truth table for only two inputs can show commutativity directly, but associativity needs the three-input relation or this algebraic argument.

Solution: The truth table is XOR. Both (a XOR b) XOR c and a XOR (b XOR c) give parity of the three bits, and a XOR b=b XOR a. Thus the operation is associative and commutative, A.

Original paper, page 15 · Answer key

1 mark · MCQ
Report issue

Boolean Algebra & Logic Gates

Question 16, GATE 2015: For Boolean variables define X#Y=X′+Y′, where prime means NOT and + means OR. Consider S1: (P#Q)#R=P#(Q#R); S2: Q#R=R#Q. Which holds for all Boolean P,Q,R? (A) only S1; (B) only S2; (C) both; (D) neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. By De Morgan, X′+Y′=NOT(XY). For the counterexample, 0#1=1 and 1#1=0, so the left grouping is 1#1=0 while the right grouping is 0#0=1.

2. X#Y=¬X+¬Y is NAND and is commutative. It is not associative: P=0, Q=1, R=1 gives(P#Q)#R=0 while P#(Q#R)=1. Thus only S2, B.

Original paper, page 58 · Answer key

2 marks · MCQ
Report issue

Asked again GATE 1992, Q2(i) (same question)

Commutative but nonassociative operator

Boolean Algebra & Logic Gates

Question 2.8, GATE 1998: Which is commutative but not associative: AND, OR, NAND, XOR?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

NAND is symmetric in its arguments because ¬(ab)=¬(ba), so it is commutative. To test associativity, take a=0, b=1, c=1. Then (0 NAND 1) NAND 1=1 NAND 1=0, while 0 NAND(1 NAND 1)=0 NAND 0=1. The two groupings differ, proving nonassociativity. AND, OR and XOR are associative as well as commutative. Thus C; a single counterexample is enough to refute an asserted universal associative law.

Original paper, page 4

Report issue

Asked again GATE 1998, Q2.8 (same question)

Commutative but nonassociative gate

Boolean Algebra & Logic Gates

Question 2(i), GATE 1992: Which operation is commutative but not associative: AND, OR, XOR, NAND?
Question 2(i), GATE 1992: Which operation is commutative but not associative: AND, OR, XOR, NAND?
Tap to enlarge
Select all that apply
Answer & solution

Answer: D: NAND (no official key was published)

NAND(a, b)=¬(ab), unchanged when a and b are exchanged, so it is commutative. To refute associativity choose a=0, b=1, c=1. Then NAND(NAND(0, 1), 1)=NAND(1, 1)=0, whereas NAND(0, NAND(1, 1))=NAND(0, 0)=1. AND, OR and XOR are associative as well as commutative. A single counterexample suffices to disprove the NAND associativity identity for all triples.

Original paper, page 1