I'm working on a problem and I've managed to design an efficient algorithm, but I'm stuck at the last part.
After some processing I'm left with a tree and I have to answer several queries of the form $(x,y)$, such that for each such query we have to print the minimum cost edge on the path from $x$ to $y$.
Now, this can be done by getting the smaller value between the shortest edge on the path from $x$ to $\text{lca}(x, y)$ and the shortest edge on the path from $y$ to $\text{lca}(x, y)$.
My question is, how do we actually get the min-cost edge on the path from say $x$ to $\text{lca}(x, y)$ ? Do we just simply use a breadth first search? And wouldn't that actually beat the purpose of computing the lowest common ancestor?