Dec 28, 2008

An algorithm to find total number of unique path from (0,0) to (m,n) in an m*n grid . You are only allowed to move either RIGHT or DOWN . Each cell

An algorithm to find total number of unique path from (0,0) to (m,n) in an m*n grid . You are only allowed to move either RIGHT or DOWN . Each cell of grid is of dimension 1 * 1 .
Ex : 3 * 3 grid total number of unique path is 6 .

int func(int m,int n)
{
/*if(m==0&&n==0)
return 1;
if(m<0||n<0)
return 0;*/
if(m==0||n==0)
return 1;
return func(m-1,n)+func(m,n-1);
}

No comments:

Post a Comment