I have undirected weighted linear tree (path tree) with $n$ nodes ,and a weight function on edges $\omega: \mathbb{N}\to \mathbb{N}$, additionally given $k\in \mathbb{N}$, How we can find a path with lenght $k$ that have minimum number of edges in $O(n)$?
I think as follow: Run Bellman Ford for each node and then select a path with length $k$ and minimum number of edges. Unfortunately runtime $\omega(n)$.