Data Structures & AlgorithmsVery hardGATE CS · TCS NQT

Every element of the circular array [1, 2, 3, 4] is replaced by the sum of its two circular neighbours, taken modulo 10, simultaneously. Do this 2 times. What is the value at index 0 afterwards?

  1. A. 9
  2. B. 8
  3. C. 10
  4. D. 12

Correct answer: B. 8

Compute the whole new array after each round before replacing values; updating in place mixes old and new values. After round one the array is 6, 4, 6, 4.

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

Exams that ask this topic