Data Structures & AlgorithmsHardICPC regional · GATE CS
Problem: On the 4-cycle C4 (vertices 0-1-2-3-0), a walker starts at 0 and takes exactly 3 steps, each to an adjacent vertex. How many walks of length 3 end at vertex 0?
- A. 1
- B. 0
- C. 2
- D. 3
Correct answer: B. 0
C4 is bipartite, so every walk of odd length ends on the opposite colour class from its start. Vertex 0 is in the same class as the start only for walks of even length, so the count is zero.
More Coding Interview Problems questions
- Problem: The array [7, 3, 9, 1, 5] is processed by a selection that finds the position of the maximum, removes it, and repeats. The…
- Problem: How many 4-digit numbers (1000–9999) are palindromes (read the same forwards and backwards in decimal)?
- Problem: The string "abcabcabc" has how many distinct substrings of length 3?
- 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…
- 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…