Watch it for revision...You can learn DP by analyzing the optimal substructure and overlapping subproblems.
Thank you, viewers. My name is Abhilash. I am a Ph.D. scholar at IIT Jammu, CSE Dept. I research in the field of Cryptology.
//Code//
#include stdio.h
int M[4][70];
int minVal(int x,int y){
if(x less than y)return x; else return y;
}
int main(){
int C[5]={1,5,8},n=3,V=10;
int i,j;
for(i=0;i is less than or equal to n;i++){
for(j=0;j is less than or equal to V;j++){
if(i==0 && j is greater than 0){
M[i][j]=9999;// 9999 == oo
}
else if(j==0){
M[i][j]=0;
}else if(j-C[i-1] is less than 0){
M[i][j]=M[i-1][j];
}
else{
M[i][j]=minVal(1+M[i][j-C[i-1]],0+M[i-1][j]);
}
printf("%d\t",M[i][j]);
}
printf("\n");
}
return 0;
}
On this page of the site you can watch the video online Coins Change Problem - (Recursive+DP+Code)// Code Spectrum with a duration of online in good quality, which was uploaded by the user Code Spectrum 05 February 2023, share the link with friends and acquaintances, this video has already been watched 30 times on youtube and it was liked by 1 viewers. Enjoy your viewing!