Skip to content

Instantly share code, notes, and snippets.

@jitsceait
Created May 4, 2014 03:53
Show Gist options
  • Select an option

  • Save jitsceait/39129806798bec996f1d to your computer and use it in GitHub Desktop.

Select an option

Save jitsceait/39129806798bec996f1d to your computer and use it in GitHub Desktop.
This program implements optimized version of dynamic programming approach for all possible path problem
int PossiblePaths(int m,int n){
int Table[n];
int diagonal_sum =0;
int i,j;
for(i=0;i<=n; i++){
Table[i] =1;
}
for(i=1; i<=m; i++ ){
for(j=1; j<=n; j++){
diagonal_sum = Table[j-1];
Table[j] = Table[j] + Table[j-1] + diagonal_sum;
}
}
return Table[n];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment