DEV Community

Pritam Chougale
Pritam Chougale

Posted on

Why is there so much fuss about dynamic programming in interviews, when it hardly matters in real-time projects?

“When it hardly matters in real-time projects”. This statement is extremely incorrect. Just a few examples:

Machine learning algorithms like Viterbi algorithm or the ones using Markov Chain or HMM are infact completely based around Dynamic Programming

Bioinformatics requires a lot of sequencing algorithms which are rooted in DP.

String matching is done via KMP and uses of Edit Distance - Again extremely important for a lot of real world things like Autocompletion.

A common example would be, many delivery apps (I have heard of UrbanClap) model their problem as a graph and use greedy/dp algorithms to actually solve the delivery problem

More importantly - let us understand what is the principle behind Dynamic Programming?

It mainly consists of 3 steps:

Step 1: Dividing the original problem into smaller subproblems

Step 2: Solving these subproblems and combining their results to get the big problem’s result

Step 3: Remembering the subproblems you solved in the past and reusing the results rather than recalculating for them (Memoization)

Don’t you think these 3 steps are actually very important for solving real problems?

That is why they are given importance in an interview. The idea is to pick the best problem solvers.

Want to know how to start preparing for coding interviews?
Visit: programmingpathshala.com and take a 7 days free trial.

Top comments (0)