Data Structures & AlgorithmsVery hardICPC regional · GATE CS
Problem: What is the number of walks of length 4 that start and end at the same vertex in the complete graph K3 (vertices 0, 1, 2, each pair adjacent), summed over all starting vertices?
- A. 6
- B. 18
- C. 48
- D. 16
Correct answer: B. 18
Closed walks from a vertex in K3 number (2⁴ + 2)/3 = 6, so the trace over 3 vertices is 18. Forgetting to sum over starts gives 6, all walks of length 4 total 3 · 2⁴ = 48, and 16 assumes every walk from one vertex returns.
More Coding Interview Problems questions
- Problem: How many integers in [1, 999] have digits that are strictly increasing (each digit larger than the previous)? Run the code…
- Problem: What is the sum of the first 50 terms of the sequence 1, 1, 2, 3, 5, ... (Fibonacci numbers F(1) to F(50), with F(1)=F(2)=1)? Run…
- Problem: How many pairs (i < j) of [2, 4, 6, 9, 12, 15] have gcd(ai, aj) = 3? Run the code. python from math import gcd a = [2, 4, 6, 9…
- Problem: How many integers in [1, 300] are divisible by exactly two of the numbers 2, 3 and 5? Run the code. python print(sum(1 for x in…
- Problem: What is the minimum number of perfect cubes (1, 8, 27, ...) that sum to 100? Run the DP. python INF = 10 9 dp = [0] + [INF] 100…
- Problem: How many integers in [1, 200] have an even number of 1-bits in their binary form? Run the code. python print(sum(1 for x in…