Data Structures & AlgorithmsHardGATE CS · competitive programming

Let A = [5, 3, 6, 2, 7, 1] (0-based), with P[0] = 0 and P[i] = A[0] ⊕ … ⊕ A[i−1]. What is A[2] ⊕ A[3] ⊕ A[4]?

  1. A. 3
  2. B. 4
  3. C. 7
  4. D. 0

Correct answer: A. 3

Compute it directly: 6 ⊕ 2 = 4 and 4 ⊕ 7 = 3. This equals P[5] ⊕ P[2]. The trap 4 drops A[4] from the range.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic