Bird
Raised Fist0

Given the final maximum XOR value is 15 for an input array of 4-bit numbers, and the prefix set at bit 3 iteration is {0, 8, 7, 15}, which pair of numbers could have produced this maximum XOR?

hard🔄 Reverse Engineer Q9 of Q15
Bit Manipulation - Maximum XOR of Two Numbers
Given the final maximum XOR value is 15 for an input array of 4-bit numbers, and the prefix set at bit 3 iteration is {0, 8, 7, 15}, which pair of numbers could have produced this maximum XOR?
A0 and 15
B8 and 7
C7 and 15
D8 and 15
Step-by-Step Solution
Solution:
  1. Step 1: Maximum XOR is 15 (binary 1111), so pair differs in all 4 bits.

    0 (0000) XOR 15 (1111) = 15.
  2. Step 2: Check pairs: 8 (1000) XOR 7 (0111) = 15, 0 XOR 15 = 15, 7 XOR 15 = 8, 8 XOR 15 = 7.

    Only 0 and 15 or 8 and 7 produce 15.
  3. Step 3: Given prefix set includes 8 and 7, the pair 8 and 7 is valid and matches prefix set.

    8 and 7 is correct.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    8 ^ 7 = 15 matches max XOR [OK]
Quick Trick: Max XOR 15 means pair differs in all bits [OK]
Common Mistakes:
MISTAKES
  • Picking pairs that don't XOR to max value
Trap Explanation:
PITFALL
  • Candidates confuse which pairs produce max XOR from prefix sets.
Interviewer Note:
CONTEXT
  • Tests reverse reasoning from output to input pairs.
Master "Maximum XOR of Two Numbers" in Bit Manipulation

3 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Bit Manipulation Quizzes