Data Structures & AlgorithmsHardGATE CS · TCS NQT

A cellular automaton of 6 cells starts as [1, 0, 0, 0, 0, 0]. In each step every cell becomes the XOR of its two neighbours (cells outside the line count as 0). After 2 steps, what is the number of cells equal to 1?

  1. A. 3
  2. B. 4
  3. C. 6
  4. D. 2

Correct answer: D. 2

Step one turns on cell 1; step two turns on cells 0 and 2, so two cells are 1. Updating cells in place instead of simultaneously gives a different result.

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

Exams that ask this topic