Skip to main content

Command Palette

Search for a command to run...

Greedy and Dynamic Programming — My Understanding

Updated
1 min readView as Markdown
Greedy and Dynamic Programming — My Understanding

Last week in my Advanced DSA lecture, I learned about Greedy and Dynamic Programming (DP).

This is my simple understanding of these two approaches.

🟢 Greedy

Suppose I am in Mumbai and I want to go to Pune. I want to reach Pune fast, so I choose the Mumbai–Pune Expressway.

This is the Greedy approach. We choose the best option at that time.

Greedy = Fast decision, but it may not always give the best result.

🔵 Dynamic Programming

In DP, I can check different ways and different conditions to find the best solution. I solve small problems and save their results to use again.

DP = More calculation, but it can give a better and accurate result.

This is my understanding from the lecture. I am still learning and practicing these concepts.