Data Structures & AlgorithmsModerateWipro · Capgemini pattern
What is the maximum number of edges in a directed ACYCLIC graph with 6 vertices (no parallel edges)?
- A. 30
- B. 15
- C. 36
- D. 5
Correct answer: B. 15
Fix a topological order; every edge must go from an earlier to a later vertex, so at most one edge per unordered pair: C(6, 2) = 15, achieved by joining every earlier vertex to every later one. 30 would contain both u→v and v→u, a cycle; 5 is a mere path.
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 common subsequence of PLACEMENT and COMPLETE?
- Keys 15, 10, 20, 8, 12, 25, 6, 11, 13, 9 are inserted into an empty BST. What is the height of the tree (edges on the longest root-to-leaf…
- Keys 10, 20, 30, 25, 28 are inserted into an empty AVL tree. Which rotations are performed, in order (named by imbalance case)?
- Floyd–Warshall on vertices 0–3 starts from the weight matrix below (∞ = no edge). After the iteration with k = 0 (paths allowed to go…
- How many distinct spanning trees does the graph with vertices A, B, C, D and edges A–B, B–C, C–D, D–A, A–C (a 4-cycle plus one diagonal)…
- A recursive segment tree is built over an array of n = 6 elements (each internal node splits its range into two halves; leaves are single…