ProgrammingVery hard
How many subsets of {1, 2, 3, 4} (including the empty set) have XOR equal to 0?
- A. 1
- B. 2
- C. 3
- D. 4
Correct answer: B. 2
Only the empty set and {1, 2, 3} have XOR 0, because 1 ^ 2 ^ 3 = 0. Checking all 16 subsets confirms no other one works.
More C Programming questions
- What is the result of (0xFFu >> 4) | (0x0Fu << 4) & 0xFF?
- How many times does cnt++ run in: for (i = 0; i < 10; i++) for (j = i; j < 10; j++) cnt++; ?
- How many iterations does for (i = 1; i < 1024; i = 2) do?
- A binary search over n = 10^6 sorted records, in the worst case, takes how many loop iterations?
- A sieve of Eratosthenes up to n = 100 marks composites by starting each prime p at pp, and only for pp <= n. How many marking operations…
- With fib(1) = fib(2) = 1, what is the largest n for which fib(n) fits in a signed 64-bit long long?