Data Structures & AlgorithmsModerateTCS NQT · Infosys
Problem: Starting with 1, the operations are: multiply by 2, then add 3, applied three times in a row (x → 2x + 3). What is the result after the three operations?
- A. 13
- B. 50
- C. 61
- D. 29
Correct answer: D. 29
1 → 5 → 13 → 29 under x → 2x + 3. Two applications give 13, adding first and then doubling gives 8, 22, 50, and a fourth application gives 61.
More Coding Interview Problems questions
- Problem: Find the number of integers n in the range 2 to 100 for which n and n + 2 are both prime (twin primes, counted by the smaller…
- Problem: The string "abcabcabcabc" is split into consecutive chunks of length 5 from the left (the last chunk may be shorter). How many…
- Problem: A binary search tree is built from the values 15, 10, 20, 8, 12, 17, 25 inserted in that order. What is the number of leaves…
- Problem: A stack-based simulation begins with an empty stack. Operations in order: push 4, push 7, push 2, pop, push 9, pop, push 5. What…
- Problem: A tree on 5 nodes is given by edges 1-2, 2-3, 2-4, 4-5. The diameter (in edges) of this tree is what value?
- Problem: A sequence is defined by s(1) = 1, s(2) = 2, and s(n) = s(n−1) + s(n−2) for n ≥ 3. What is the remainder when s(12) is divided by…