void findPaths(int x, int y, int depth) { if (isEnd(x,y)) showSolution(); // One path will be marked by letters A,B,C... else { maze[x][y] = 'A' + depth; if (x && (maze[x-1][y]=='1')) findPaths(x-1,y,depth+1); if (y && (maze[x][y-1]=='1')) findPaths(x,y-1,depth+1); if ((x+1<size) && (maze[x+1][y]=='1')) findPaths(x+1,y,depth +1); if ((y+1<size) && (maze[x][y+1]=='1')) findPaths(x,y+1,depth +1); maze[x][y] = '1'; } }
On Oct 12, 3:01 pm, Rahul Kumar Patle <patlerahulku...@gmail.com> wrote: > Pls help to solve this que.. does any one have DP solution for following > que. > > http://www.geeksforgeeks.org/archives/24488 > section 5/question 2 > > Write a program to find all the possible paths from a starting point to > dest point in a maze(2-D array). > > ex: 1 0 1 0 > 1 1 1 1 > 0 1 0 1 > 0 0 1 1 > > If there is a block it’s represented by 0. > If there is a path it’s represented by 1. > > -- > Thanks and Regards: > Rahul Kumar Patle > M.Tech, School of Information Technology > Indian Institute of Technology, Kharagpur-721302, > India<http://www.iitkgp.ac.in/> > Mobile No: +91-8798049298, +91-9424738542 > Alternate Email: rahulkumarpa...@hotmail.com > [image: > Linkedin]<http://www.linkedin.com/profile/view?id=106245716&trk=tab_pro> > [image: Twitter] <https://twitter.com/rahulkumarpatle> > <https://www.facebook.com/rkpatle> -- 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.