Go Job Hunting at the LQ Job Marketplace
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org Find the path to the exit (C code)
 User Name Remember Me? Password
 Programming This forum is for all programming questions. The question does not have to be directly related to Linux and any language is fair game.

Notices

 12-07-2006, 02:58 PM #1 linuxlover1 Member   Registered: Jun 2003 Location: UK Posts: 54 Rep: Find the path to the exit (C code) Hello to all....! The problem is ... i am trying to solve the below problem... ####\$# #-##-- #---#- #-#-#- ##^--- ##-##- '#': wall , '-': free path , '\$':the exit , '^': the man Well...i have to program the man to find the exit from the 2D maze.....but the alogorithm must not use recursion..... Any ideas.. ?? I do not know Graph theory...and stuff like Link-lists...stucks or queues.....I need to solve this just with arrays and no recursion. The Output: ####\$# #-## | | #---# | #-#-# | ##^| | | ##-##- "|" : the steps to the exit. Please help...Thanks in advance !!
 12-07-2006, 04:41 PM #2 matthewg42 Senior Member   Registered: Oct 2003 Location: UK Distribution: Kubuntu 12.10 (using awesome wm though) Posts: 3,530 Rep: please repost your ascii art in [code] tags.
 12-07-2006, 09:09 PM #3 taylor_venable Member   Registered: Jun 2005 Location: Indiana, USA Distribution: OpenBSD, Ubuntu Posts: 892 Rep: Iteration and recursion are two sides of the same coin. Anything one can do, the other can do. One way to approach this problem, if recursion seems natural to you, is to write a recursive solution and convert it to iteration. (Usually this means converting the automatic state of the program's stack into explicit state within a loop.)
 12-07-2006, 09:43 PM #4 matthewg42 Senior Member   Registered: Oct 2003 Location: UK Distribution: Kubuntu 12.10 (using awesome wm though) Posts: 3,530 Rep: There are lots of path finding algorithms. One of the simpler to implement is Dijkstra's Algorithm. It's not very efficient though. For a really good discussion of path finding algorithms, have a look at this extremely good site.