logo

Dynamic Programming



What's Dynamic Programming ? ...

Basically its memoised iteration ...

Under this paradigm, we will be learning :


Fibonacci Series

  • By normal recursion : we know that f(n) = f(n-1) + f(n-2). To calculate f(n-1) and f(n-2) we follow the same procedure separately. We finally end up calculating many redundant values of lesser fibonacci numbers.
  • With the help of Dynamic programming, we just find the fibonacci number only once and use it for further calculations.

Click the button below to see how dynamic programming is used to deal with this problem ...


Insertion Sort

  • We iterate from arr[1] to arr[n] over the array.
  • Compare the current element (key = arr[i]) to its predecessor.
  • If the key element is smaller than its predecessor, compare it to the elements before. Move the greater elements one position up to make space for the swapped element.
  • By this way, we get the sorted array finally.

Click the button below to see how selection sort works ...