Data Structures & AlgorithmsHardGATE CS · Product-company placement
DFS on the directed graph with adjacency lists A: CDG; B: –; C: –; D: BCF; E: –; F: CE; G: CE 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 E?
- A. 8/9
- B. 3/4
- C. 8/10
- D. 9/10
Correct answer: A. 8/9
Simulating with one tick per discovery and per finish gives d[E] = 8, f[E] = 9; 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
- What is the length of the longest BITONIC subsequence (strictly increasing then strictly decreasing; either part may be empty) of [19, 10…
- Keys 32, 44, 47, 53, 93, 54, 12, 22, 68, 97 are inserted into an empty AVL tree (giving preorder 53, 44, 22, 12, 32, 47, 68, 54, 93, 97)…
- Using parts 3, 4, 5 (each any number of times), in how many ways can 10 be written as an ORDERED sum (so 1 + 2 and 2 + 1 count separately)?
- The boolean expression T ^ F | T & T (T = true, F = false, & = AND, | = OR, ^ = XOR) can be fully parenthesised in 5 ways. In how many of…
- Coins of denominations 1, 3, 6, 8 are available in unlimited supply. What is the minimum number of coins needed to make 28, and how many…
- What is the length of the shortest string that has BOTH INTERVAL and RECESSION as subsequences (shortest common supersequence)?