Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

Introduction to Dynamic Programming

Rating
-
Sold
-
Pages
2
Uploaded on
15-03-2023
Written in
2022/2023

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 memory for future use. Dynamic Programming can be used to solve a wide range of problems, such as finding the shortest path in a graph, calculating the optimal sequence of operations for a given task, or maximizing profits in a business. Dynamic Programming involves breaking down a larger problem into smaller, more manageable subproblems, and solving them one by one. The solutions to these subproblems are then combined to solve the original problem. Dynamic Programming is particularly useful in situations where the same subproblems need to be solved repeatedly, and it can help to reduce the computational time required to solve the problem. However, it can also require a significant amount of memory to store the solutions to all of the subproblems. Overall, Dynamic Programming is a powerful tool for solving complex problems in a more efficient way. With its ability to break down problems into smaller, more manageable subproblems, it is a valuable technique for a wide range of applications in computer science, mathematics, and other fields.

Show more Read less
Institution
Course

Content preview

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

Written for

Institution
Course

Document information

Uploaded on
March 15, 2023
Number of pages
2
Written in
2022/2023
Type
Class notes
Professor(s)
Raj vikramaditya
Contains
All classes

Subjects

$8.76
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
utkarshjain

Get to know the seller

Seller avatar
utkarshjain
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions