LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
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



Reply
 
Search this Thread
Old 12-07-2006, 03:58 PM   #1
linuxlover1
Member
 
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, 05:41 PM   #2
matthewg42
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, 10:09 PM   #3
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 41
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, 10:43 PM   #4
matthewg42
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.
 
  


Reply


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/Novell 0 12-21-2004 02:06 PM
exit code 2 -- pppd eduac Linux - Software 3 11-21-2003 06:19 AM
atexit and exit code GŠutama Programming 3 11-01-2003 03:15 AM
pppd exit code = 10 eduac Linux - Hardware 1 10-20-2003 03:57 AM
pppd exit code 16 ksgill Linux - Newbie 8 07-12-2003 11:20 PM


All times are GMT -5. The time now is 12:35 PM.

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