Re: [algogeeks] Number of paths

2013-02-22 Thread alexsolo
http://tafakuri.net/?p=66 def num_paths_to_grid_bottom(numRowCells, numColumnCells): currRow = [1 for x in range(numColumnCells + 1)] # the number of nodes to consider = numRowCells + 1 for numRow in range(1, numRowCells + 1): for numColumn in range(1,

Re: [algogeeks] Number of paths

2013-02-21 Thread Gaurav Rana
(m+n)C(n) On Thu, Feb 21, 2013 at 1:26 PM, shady sinv...@gmail.com wrote: Given a matrix of size mXn, find the number of paths from the top left cell to the bottom right cell. BFS is one way... any other approach ? -- You received this message because you are subscribed to the Google

Re: [algogeeks] Number of paths

2013-02-21 Thread shady
How did you directly arrive at that solution ? Can you please explain On Thu, Feb 21, 2013 at 1:52 PM, Gaurav Rana gauravran...@gmail.com wrote: (m+n)C(n) On Thu, Feb 21, 2013 at 1:26 PM, shady sinv...@gmail.com wrote: Given a matrix of size mXn, find the number of paths from the top left

Re: [algogeeks] Number of paths

2013-02-21 Thread Karthikeyan V.B
Assuming that u can either move down or right, Using Dynamic Programming, a DP equation can be framed like this : Paths[i][j] = paths[i][j-1] + paths[i-1][j] By filling the entire matrix, result will be in Paths[m-1][n-1]. -- You received this message because you are subscribed to the Google

Re: [algogeeks] Number of paths

2013-02-21 Thread Gaurav Rana
number of ways to choose n right selections out of total (n+m) selection.(m+n)C(n) On Thu, Feb 21, 2013 at 2:29 PM, Karthikeyan V.B kartmu...@gmail.comwrote: Assuming that u can either move down or right, Using Dynamic Programming, a DP equation can be framed like this : Paths[i][j] =

Re: [algogeeks] Number of paths

2013-02-21 Thread Nishant Pandey
+1 for above approach , its called memotization .. it helps reducing redundant recursive call for the same matter. On Thu, Feb 21, 2013 at 2:29 PM, Karthikeyan V.B kartmu...@gmail.comwrote: Assuming that u can either move down or right, Using Dynamic Programming, a DP equation can be framed

Re: [algogeeks] Number of paths

2013-02-21 Thread Nikhil Karnwal
No. of paths =(n+m-2)C(n-1) Total number of times u have to change the column is m-1 and row is n-1 thus u have total (n-1+m-1) operations to do and out of these operations u have to choose n-1 operation for changing rows. ok. On Thu, Feb 21, 2013 at 2:29 PM, Karthikeyan V.B

Re: [algogeeks] Number of paths

2013-02-21 Thread kumar ankit
If the allowable moves are : one step towards Right, and one step towards bottom Explanation for (m+n) C n: you may represent the path using a String consisting of only R and D, where R is a right move and D is a downward move. To go from (1,1) to (m,n) the length of the string will be (m+n) as

Re: [algogeeks] Number of paths

2013-02-21 Thread kumar ankit
Well, (m+n) C (n) is the answer only in the case the allowable moves are : one step towards Right, and one step towards bottom. On Thu, Feb 21, 2013 at 2:05 PM, shady sinv...@gmail.com wrote: How did you directly arrive at that solution ? Can you please explain On Thu, Feb 21, 2013 at 1:52

[algogeeks] Number of paths

2013-02-20 Thread shady
Given a matrix of size mXn, find the number of paths from the top left cell to the bottom right cell. BFS is one way... any other approach ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving