100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Introduction to Dynamic Programming $8.26   Add to cart

Class notes

Introduction to Dynamic Programming

 3 views  0 purchase
  • Course
  • Institution

Dynamic Programming is a problem-solving technique used in computer science and mathematics to optimize problems that can be divided into smaller subproblems with overlapping substructures. The key idea behind dynamic programming is to solve each subproblem only once and store the solution in memor...

[Show more]

Preview 1 out of 2  pages

  • March 15, 2023
  • 2
  • 2022/2023
  • Class notes
  • Raj vikramaditya
  • All classes
avatar-seller
DP 1. Introduction to Dynamic Programming | Memoization | Tabulation | Space
Optimization Techniques

This is the ultimate dynamic programming playlist playlist. This series will
contain the maximum number of videos which none of the other channels have given
this series will be containing around 60 to 70 videos. The content is going to be
so crisp and so clear that you will learn completely and you will have no doubts.
The series is going to be entirely in english so it does n't matter where you 're
where you are located you're going to understand each and every word of this series
so when i say tabulation it means a bottom up dynamic programming. There will be a
lot of topics which you'll feel like we know this topic but i'll still recommend
you to watch it till the end. entire recursion playlist it has 19 videos even if
you do n't do 19 videos i will still recommend you to do the first 10 videos. The
recurrence relation again i have already explained this so i 'll not be explaining
recursion relations in depth in any of the lectures i'm assuming you are very very
good at recursion so the recursion relation comes up to be f of n minus 1 plus f n
minus 2 without any doubt.


Recursion would have gone and created ff1 then it would have called f of 0 this
would have returned 1. When f of 5 calls f of 4 and f of 3 first it goes completes
f of. 4 first f of four will go complete itself and come back then f of three will
complete itself. F of 3 is f of 1 plus 1 gives you 2 so this is 2 this returns you
2. Memoration is where something as memo i asian jumps in what is memoration.
Memoration stores the value of sub problems in a map slash table. Memororation is
how you're going to solve a normal recursion if you are going to use memorization.
At max the sub problems are from 0 to 5 so can i say at max the sub. problems are 0
to. 5. Initially you will keep everyone as minus 1tk initially you can keep
everyone minus 1. so whenever you go to f of 5 it 's minus 1 you go f of 4 minus 1,
f of 3 minus 1 and f of 2. so what we do is we return this value 2 directly so that
's how we do it'


In order to convert a recursion to a dynamic programming i implemented kind of
three steps where i can say the step zero is declaring an array considering the
size of the sub problems like over here there were n sub problems thereby i
declared an array of size n. step one storing the answer which is being computed
for every sub problem step two checking if the sub problem has been previously
solved if it is previously solved then the value will not be -1 thereby i can
easily return it. i 've taught you the first step which is memoization i have to
teach you the time complexity and the space complexity let 's analyze that as well
so over here if i just run it you'll see five coming out of five so step one step
two step declaration three steps so in this way you can avoid using global
variables. How do you convert a recursion into a tabulation format? We have covered
up memoration with time complexity as well as space complexity. We use a big o of n
for array that is what i 'm using for array. We start from the base case and you go
to the required answer remember a pattern in recursion.


The recurrence will never be executed before 2 so from 2 to n is what you write
okay and you 're going to write dp of i because that's what you wrote over there in
recursion equal to instead of f of n minus 1 you 'll write i minus 1 plus dp of i
minus 2 similar stuff you'll write just you change it to i. The previous stored as
the fibonacci number so in this way you can optimize the space as well i have
eliminated the space used i 've used just a couple of variables so if you try to
run this you 'll see this is working absolutely fine. Going forward in every
problem we will be observing this pattern where we will use the previous guys in
the second previous guys. If you have any doubts you can put that into the comment
section i will be trying to reply that if it 's a unique doubt and if you have

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller utkarshjain. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $8.26. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

78600 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$8.26
  • (0)
  Add to cart