LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, 02: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, 04:41 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
please repost your ascii art in [code] tags.
 
Old 12-07-2006, 09:09 PM   #3
taylor_venable
Member
 
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
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:38 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
Open Source Consulting | Domain Registration