Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 12-07-2006, 02:58 PM   #1
Registered: Jun 2003
Location: UK
Posts: 54

Rep: Reputation: 15
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 !!
Old 12-07-2006, 04:41 PM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
please repost your ascii art in [code] tags.
Old 12-07-2006, 09:09 PM   #3
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
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.)
Old 12-07-2006, 09:43 PM   #4
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exit Code: 7 dbzw SUSE / openSUSE 0 12-21-2004 01:06 PM
exit code 2 -- pppd eduac Linux - Software 3 11-21-2003 05:19 AM
atexit and exit code GŠutama Programming 3 11-01-2003 02:15 AM
pppd exit code = 10 eduac Linux - Hardware 1 10-20-2003 02:57 AM
pppd exit code 16 ksgill Linux - Newbie 8 07-12-2003 10:20 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:09 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration