← All problemsSign in

Hamiltonian Tree

CodeChefRating 2810Open on judge ↗

You are given a tree $T$ with $N$ vertices. Recall that a tree is a connected graph with $N-1$ edges. Determine the **minimum** number of edges you must add to $T$ to get a new graph $G$ such that $G$ has a Hamiltonian path. Note: A graph $G$ is said to have a hamiltonian path if and only if there exists a simple path in $G$ that includes every vertex exactly once. ### Input - The first line of

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start