Making Stars
A tree of $N$ nodes and $N - 1$ edges is a connected undirected graph without cycles. A given tree of $N$ nodes is called a **star** if there exists a node $X$ such that node $X$ is directly connected to each of the other $N - 1$ nodes. Now, for any given tree $T$ we define $f(T)$ as the **minimum** number of needed operations to convert the tree into a **star** with the following operations: -
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.
Sign in to chat with the tutor and save your progress.
Sign in to start