Data Structures & AlgorithmsHardICPC regional · Product Company SDE
Problem: A Rule 90 cellular automaton on an infinite line starts with a single live cell. A cell's next state is 1 exactly when its two neighbours differ (left XOR right). After 3 generations, how many live cells are there?
- A. 5
- B. 4
- C. 3
- D. 6
Correct answer: B. 4
Each generation sets a cell to the XOR of its two neighbours, which produces a Sierpiński-like pattern. Including the cell's own state in the XOR gives Rule 150 and a different count.
More Coding Interview Problems questions
- Problem: A lucky 4-digit ticket has the sum of its first two digits equal to the sum of its last two digits. Each ticket number runs from…
- Problem: A grid of 5×5 cells has 'X' blocked cells at (0,2), (1,2), (2,2), (3,2) (row, column, 0-indexed); the rest are open. Cells…
- Problem: On a grid, a diagonal step costs 2 and a straight step costs 1 (moves are up, down, left, right, and the four diagonals). What is…
- Problem: The cycle graph C8 has vertices 0–7 with i adjacent to (i+1) mod 8. How many unordered pairs of vertices are at distance exactly…
- Problem: A height-balanced binary search tree is built over the sorted keys 1, 2, …, 10 by always taking the middle element as the root…
- Problem: Given the parent array p = [−1, 0, 0, 1, 1, 2, 4, 4] for nodes 0–7 (node 0 is the root), how many nodes have exactly one child?