Comparative Analysis of Dynamic and Greedy Approaches for Dynamic Programming