Data Structures & AlgorithmsModerateCodeforces Div 2 C · GATE CS
Connected undirected simple graph on vertices 0 to 6 with edges: 1–3, 2–3, 0–1, 2–5, 4–5, 2–4, 3–6. What is the maximum number of edges in a simple path (no repeated vertex) in this graph?
- A. 4
- B. 6
- C. 7
- D. 5
Correct answer: D. 5
Exhaustive search over simple paths finds a longest one with 5 edges. The largest shortest-path length (4) measures a different thing, and n−1 assumes a Hamiltonian path that need not exist.
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
- Connected undirected simple graph on vertices 0 to 5 with edges: 2–3, 4–5, 1–4, 2–5, 0–4, 0–2, 3–4. What is the maximum number of edges in…
- Connected undirected simple graph on vertices 0 to 6 with edges: 0–4, 0–5, 3–6, 0–6, 1–5, 1–6, 0–2. What is the maximum number of edges in…
- Connected undirected simple graph on vertices 0 to 6 with edges: 1–2, 2–6, 4–5, 3–5, 1–6, 1–5, 0–2. What is the maximum number of edges in…
- Connected undirected simple graph on vertices 0 to 4 with edges: 0–1, 1–3, 2–4, 1–2, 1–4. What is the maximum number of edges in a simple…
- Directed graph on vertices 0 to 5 with edges: 3→5, 5→1, 4→0, 3→4, 3→2, 1→4, 0→4, 1→3, 3→1, 0→2, 3→0, 4→3, 0→5, 5→4, 1→5, 5→3, 4→5, 1→2…
- Directed graph on vertices 0 to 6 with edges: 1→4, 3→6, 0→2, 1→3, 6→2, 4→3, 1→0, 6→4, 2→5, 4→1, 4→6, 1→5, 1→6, 0→6, 0→4, 6→1. What is the…