Coins Change Problem - (Recursive+DP+Code)// Code Spectrum

Publicado em: 05 Fevereiro 2023
no canal de: Code Spectrum
30
1

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;
}


Nesta página do site você pode assistir ao vídeo on-line Coins Change Problem - (Recursive+DP+Code)// Code Spectrum duração online em boa qualidade , que foi baixado pelo usuário Code Spectrum 05 Fevereiro 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 30 vezes e gostou 1 espectadores. Boa visualização!