GATE Computer ScienceVery hardGATE CSE
A DFS is run on a directed graph with adjacency lists 0:[1,4], 1:[2,5], 2:[0,3], 3:[1], 4:[5,6], 5:[3], 6:[4,5], 7:[3,6]. Vertices are tried in increasing order, restarting at the smallest unvisited vertex. How many edges are classified as cross edges, and how many as back edges?
- A. 6 cross, 2 back
- B. 5 cross, 4 back
- C. 5 cross, 3 back
- D. 4 cross, 4 back
Correct answer: C. 5 cross, 3 back
DFS tree edges: 6; classifying the rest by colour/discovery times gives 3 back, 0 forward and 5 cross edges.
More Algorithms questions
- In how many different ORDERED sequences of coins from {1, 4, 5} can a total of exactly 15 be formed (sequences like 1,4 and 4,1 count…
- How many binary strings of length 12 do not contain three consecutive 1s as a substring?
- Five keys k1<k2<k3<k4<k5 are searched with access frequencies 4, 2, 6, 3, 9. For a binary search tree over these keys, with the root at…
- What is the minimum number of comparisons needed in the worst case to find the SECOND smallest of 100 distinct elements?
- Consider T(n) = 2T(n/2) + n/log₂n for n ≥ 2 (n a power of 2, T(1) = 1). Which is the tightest bound? (The Master theorem in its basic form…
- Let T(n) = 2T(√n) + log₂ n for n > 2, with T(2) = 1, where n is always of the form 2^(2^k). What is the exact value of T(2^16)?