| | |
Knight's Tour Using a Stack
![]() |
•
•
Join Date: Mar 2008
Posts: 31
Reputation:
Solved Threads: 0
I'm trying to write a program in java...it's actually the famous game of "Knight's Tour" - I guess you're all familiar with it- just for a brief explanation
what I have to do is to get from the user the row and the coloumn of the square on the board where the knight wants to start moving, and from that position USING A STACK to store the square details, move around the board until the knight goes through ALL the squares of the board only once. When the knight moves into one square it cannot go to that square again, so using a stack the knight comes across a time when it reaches a dead end and that's when it comes back to the previous house
I really need some help on how to begin with this!
The whole 'stack' thing really bugs me now......i'm confused
what I have to do is to get from the user the row and the coloumn of the square on the board where the knight wants to start moving, and from that position USING A STACK to store the square details, move around the board until the knight goes through ALL the squares of the board only once. When the knight moves into one square it cannot go to that square again, so using a stack the knight comes across a time when it reaches a dead end and that's when it comes back to the previous house
I really need some help on how to begin with this!
The whole 'stack' thing really bugs me now......i'm confused
So a Stack is just a data structure that follows the Last In First Out rule (LIFO). This means that the last item placed on the stack (with an add or push method of some description) will be the next to be removed (by a call to a remove or pop method).
The Java API provides a basic Stack class that you can use (in the java.util package).
The Java API provides a basic Stack class that you can use (in the java.util package).
There are no stupid questions, only those too stupid to ask for help.
echo is a web developer's best friend. Also if you had searched the forum, you would have come up with this post about Stack. Others had the same question as you, so you could have searched to see your question answered
http://www.daniweb.com/forums/thread146631.html
http://www.daniweb.com/forums/thread146631.html
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
Other Threads in the Java Forum
- Previous Thread: Final Year Project Proposal
- Next Thread: java interest program help?
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows






