Data Structures & AlgorithmsModerateICPC regional · GATE CS
Problem: Compute C(20, 10) modulo 1,000,000,007 (the binomial coefficient).
- A. 167960
- B. 184756
- C. 92378
- D. 1048576
Correct answer: B. 184756
C(20, 10) = 184756, which is already below the modulus, so it is unchanged (compute it with Pascal's rule or factorials and modular inverses). C(20, 9) = 167960 is an off-by-one in k, C(19, 9) = 92378 is an off-by-one in n, and 2²⁰ = 1048576 sums the whole row.
More Coding Interview Problems questions
- Problem: How many prime numbers are there up to 100 (inclusive)?
- Problem: What is the LCM of the array [4, 6, 10, 15]?
- Problem: Count the pairs (i, j) with i < j in the array [1, 2, ..., 10] whose sum is divisible by 4.
- Problem: Find the majority element (appearing more than half the time) of [2, 2, 1, 1, 1, 2, 2] using the Boyer–Moore voting algorithm…
- Problem: Kadane's algorithm finds the maximum sum of a non-empty contiguous subarray of [−2, 1, −3, 4, −1, 2, 1, −5, 4]. What is that…
- Problem: The array [1, 2, 3, 4, 5, 6, 7] is rotated right by 3 positions (the last 3 elements move to the front). What is the element at…