Data Structures & AlgorithmsModerateTCS NQT · SSC CGL Tier 2
Problem: What is the largest power of 2 that is less than or equal to 1000?
- A. 512
- B. 1024
- C. 9
- D. 256
Correct answer: A. 512
2⁹ = 512 ≤ 1000 < 1024 = 2¹⁰. 1024 overshoots, 9 is the exponent rather than the power, and 256 stops one doubling early.
More Coding Interview Problems questions
- Problem: Find the smallest positive integer x such that floor(x/2) + x is at least 50.
- Problem: A set of jobs has deadlines and profits: (deadline 1, profit 20), (deadline 2, profit 40), (deadline 2, profit 30), (deadline 3…
- Problem: The insertion sort is applied to [3, 1, 2]. Count the total number of element moves (each shift of an element one place to the…
- Problem: Heap-indexed binary tree with 10 nodes (node i has children 2i and 2i+1 when ≤ 10). How many nodes lie at depth 2 (root at depth…
- Problem: In the sorted array [−3, −1, 0, 1, 2, 3], how many pairs of distinct positions (i < j) have a sum of exactly 0?
- Problem: What is C(10, 3) modulo 7?