GATE Computer ScienceHardGATE CS
A DAG has vertices 1 to 8 and edges 1→3, 2→3, 3→4, 3→5, 2→6, 6→5, 4→7, 5→7, 8→6, 1→8. How many different topological orderings does it have?
- A. 24
- B. 21
- C. 23
- D. 28
Correct answer: C. 23
Exhaustive enumeration of the 8! permutations that respect all ten edges yields 23.
More Algorithms questions
- A directed graph on vertices 0 to 11 has edges 0→1, 1→2, 2→0, 2→3, 3→4, 4→3, 5→3, 5→6, 6→7, 7→6, 8→9, 9→10, 10→8, 10→5, 11→3. What is the…
- An undirected graph has vertices 0 to 13 and edges 0-1, 1-2, 2-0, 2-3, 3-4, 4-5, 5-3, 5-6, 6-7, 7-8, 8-6, 1-9, 9-10, 10-11, 11-9, 4-12…
- In how many different ways can the 10 distinct keys 1, 2, ..., 10 be arranged in the array positions 1 to 10 of a binary max-heap (each…
- How many binary search trees on the 7 keys 1 to 7 have height exactly 4 (height counted in edges, a single node has height 0)?
- How many times is x++ executed by the following code? for (i = 1; i <= 100; i++) for (j = 1; j <= 100; j += i) x++;
- The array [7, 3, 11, 1, 9, 12, 5, 2, 10, 4, 8, 6] is sorted by merge sort. How many inversions (pairs i < j with a[i] > a[j]) does it…