divide and conquer vs greedy method vs dynamic programming