How about this one...

5 9 10 1
3 7   4 4
8 2   1 9

Check the immediate neighbors / 8 (or less) neighbors of your given cell..

Here for 5 the neighbors are 9,7,3
for 9 they are 5,3,7,4,10
for 7 they are 5,9,10,4,1,2,8,3 etc

For every cell calculate the sum of it an its neighbors, find the minimum
and add it to the table, and your path set.
keep on doing it till the cell you are adding to your path set is the n,n
th cell.


On Mon, Oct 31, 2011 at 12:52 AM, mohit verma <mohit89m...@gmail.com> wrote:

> Given a matrix you have to find the shortest path from one point to
> another within the matrix. The cost of path is all the matrix entries on
> the way. You can move in any direction (up, down, left, right, diagonally)
>
> e.g.
>
> 5 9 10 1
> 3 7 4 4
> 8 2 1 9
>
> So shortest path from (0,0) to (2,2) is (0,0)--(1,1)---(2,2). Path cost -
> 5+3+2+1=11
>
> I dont think some DP solution exist for this problem.Can it be?
>
>
> --
> Mohit
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
Anup Ghatage

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to