Data Structures & AlgorithmsHardGATE CS
DFS on the directed graph with adjacency lists A: BE; B: –; C: AD; D: AG; E: DF; F: D; G: E starts at A (scanning lists in the order shown, restarting from the alphabetically first unvisited vertex), with a clock that ticks on every discovery and every finish starting at 1. What are the discovery and finish times of F?
- A. 9/10
- B. 3/8
- C. 9/11
- D. 10/11
Correct answer: A. 9/10
Simulating with one tick per discovery and per finish gives d[F] = 9, f[F] = 10; the interval [d, f] of a vertex contains exactly the intervals of its DFS descendants.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Keys 87, 36, 57, 23, 95, 88, 77 inserted in this order build a BST. How many of the 7! orderings of these same 7 keys, inserted into an…
- DFS runs on the directed graph with adjacency lists A: EF; B: A; C: A; D: AE; E: BCF; F: G; G: B, starting at A, scanning lists in the…
- A B-tree has minimum degree t = 4 (every non-root node has between 3 and 7 keys) and height 3 (a root-only tree has height 0). What are…
- In how many different ways can 'abcdabcd' be split into a sequence of words from the dictionary {a, ab, abc, bcd, cd, d, abcd} (every…
- Six sorted files have 14, 31, 34, 35, 36, 58 records. Merging two files of sizes a and b costs a + b. What is the minimum total cost to…
- An undirected connected graph has edges A–D, A–G, B–E, C–E, C–G, D–H, D–I, F–I, G–H. How many articulation points (cut vertices) and how…