Data Structures & AlgorithmsVery hardCodeforces Div 2 C · GATE CS

Connected undirected simple graph on vertices 0 to 6 with edges: 5–6, 0–1, 0–3, 0–6, 3–6, 1–4, 1–2, 1–5. What is the maximum number of edges in a simple path (no repeated vertex) in this graph?

  1. A. 5
  2. B. 3
  3. C. 6
  4. D. 8

Correct answer: A. 5

Exhaustive search over simple paths finds a longest one with 5 edges. The largest shortest-path length (3) measures a different thing, and n−1 assumes a Hamiltonian path that need not exist.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic