Question: Assume you have a binary tree structure with weights assigned to each edge of the tree. You implement the following greedy algorithm to find the

Assume you have a binary tree structure with weights assigned to each edge of the tree. You implement the following greedy algorithm to find the shortest distance from the root to the leaf: "Starting from the root, travel from each node to its child via the edge that has the least weight. Stop when you reach a leaf." Is this greedy algorithm correct? No, because some leaves have fewer edges to the root than others No, because you may choose a path that leads to a subtree with much higher weights than subtrees encountered in other paths. Yes, because since we are picking each edge with the shortest weight, we will travel the shortest distance Yes, this is problem has an optimal substructure property
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
