Question

in one page answer this question with your own word Do you agree to use Stack...

in one page answer this question with your own word

Do you agree to use Stack data structure in backtracking technique for game development? Justify your answer with an example.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Yes,i agree to use data structure in backtracking technique for game development.

stack data structure:it is last in first out strategy.

Backtracking:Backtracking is one of the algorithm designing technique. For that purpose, we dive into some way, if that way is not efficient, we come back to the previous state and go into some other paths. To get back from current state, we need to store the previous state. For that purpose, we need stack. Some examples of backtracking is finding the solution for Knight Tour problem or N-Queen Problem etc.

my answer with example:

The easiest way to approach backtracking is to use a stack. Make your Sudoku board a class, including all the definite numbers and the possible numbers. Whenever you get to a point where you need to pick a number you create a copy of your board. One copy has the number you picked in that square marked unpickable (you don't want to pick it twice) and that copy you put on the stack. The second copy you pick the number and proceed as usual.

Whenever you come to a dead end, you throw away the board you are working on, take the top board off the stack and carry on with that board. This is the "backtracking" part: you go back to a previous state and try again down a different path. If you picked 1 before and it didn't work, then you try again from the same position but pick 2 instead.

If the Sudoku is solvable then you will eventually come to a board where you can fill in all the numbers. At that point you can throw away any part-boards left on the stack since you don't need them.

Add a comment
Know the answer?
Add Answer to:
in one page answer this question with your own word Do you agree to use Stack...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT