Infer and justify non-trivial sequence patterns
Company: Shopify
Role: Data Scientist
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Infer the rule and provide the next values; justify each in 1–2 sentences: a) 2, 3, 5, 9, 17, 33, ?; b) 1, 4, 2, 8, 4, 16, 8, 32, ?, ?; c) 1, 3, 7, 15, 31, ?; d) Fill the ? in the 3×3 grid where each row follows a consistent rule: [[7, 4, 11], [5, 9, 14], [?, 13, 18]].
Quick Answer: This question evaluates mathematical reasoning, sequence inference, and pattern-recognition competency by asking the solver to identify governing rules and justify missing terms across numeric sequences and a small grid.
Solution
General strategy: Look for (1) constant or patterned differences, (2) multiplicative/alternating operations, (3) powers/exponential forms, and (4) simple row-wise arithmetic relationships. Prefer the simplest rule that fits all given terms.
- (a) Rule: First differences double: 3−2=1, 5−3=2, 9−5=4, 17−9=8, 33−17=16. Next difference is 32, so next term = 33 + 32 = 65.
Justification: The differences follow 1, 2, 4, 8, 16 (powers of two); equivalently a_n = 2a_{n−1} − 1.
- (b) Rule: Alternating operations: ×4 then ÷2 (1 → 4 → 2 → 8 → 4 → 16 → 8 → 32 → ...).
Next two: 32 ÷ 2 = 16, then 16 × 4 = 64.
Justification: The pattern strictly alternates between multiplying by 4 and halving.
- (c) Rule: Each term is previous ×2 + 1; equivalently the sequence is 2^n − 1 (n = 1, 2, 3, ...).
Next: 31 × 2 + 1 = 63.
Justification: 1, 3, 7, 15, 31 match 2^1−1, 2^2−1, 2^3−1, 2^4−1, 2^5−1.
- (d) Rule (row-wise): Third entry = first + second.
Check: 7 + 4 = 11; 5 + 9 = 14; so ? + 13 = 18 ⇒ ? = 5.
Justification: The same row rule holds across all rows, yielding the missing value 5.
Validation and notes:
- Each proposed rule is consistent with all provided terms and yields a unique next value. While many rules can fit short sequences, the simplest consistent pattern is typically intended in interview settings.