Greedy solution

in case of optimal substructure the exampple demostrated ,how will an greedy approach different from optimal substructure.by mentors definition,it appears that optimal subtructure is same as greedy algorithm

It might be possible that greedy approach might work work the particular example taken in the video.
But there’s a good chance that greedy solution would fail.
consider this matrix
1 2 50
5 6 10
7 8 3

if you use greedy approach, you will end up taking 1-5-7-8-3 whereas best route would be 1-2-50-10-3

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.