Data Structures & AlgorithmsHardICPC regional · GATE CS
Problem: The complete directed graph on 4 vertices has an arc in both directions between every pair of distinct vertices. How many directed 3-cycles (simple cycles of length 3, counted once per cycle) does it have?
- A. 4
- B. 8
- C. 24
- D. 12
Correct answer: B. 8
Each of the C(4,3) = 4 vertex triples supports 2 directed 3-cycles: 8. Undirected triangles give 4, ordered vertex sequences give 24, and dividing 24 by 2 instead of 3 gives 12.
More Coding Interview Problems questions
- Problem: The path graph P4 has vertices 1–4 and edges 1-2, 2-3, 3-4. How many edges does its complement graph (on the same vertices…
- Problem: A complete binary tree has 15 nodes (height 3, all levels full). How many of its nodes are leaves?
- Problem: The string "abba" has how many palindromic substrings (counted by index range)?
- Problem: How many occurrences of "ab" are in "ababab" when occurrences may overlap?
- Problem: In the string "dvdf", what is the length of the longest substring with all distinct characters?
- Problem: The number of ways to tile a 1×4 strip completely using tiles of length 1 and length 2 (tiles of the same length are…