C/regarding data structures in C
Expert: Prince M. Premnath - 8/24/2008
Questionhello sir,
This s rajbalaji.ur former student came thru veera sir..,
My question s tat hw 2 use stack concept in rate in a maze problem efficiently wich deals with data structures in C
AnswerHai Dear Raj Balaji !
Well i can remember you well .. How are ? how about your college ?
Maze Problem was actually using the backtracking technique . ie . assume that a rat is running on a maze it randomly runs somewhere inside a maze once if the path was blocked obviously it will return back via the same way how it actually get into that place until it find some valid path !! this technique is called backtracking algorithm .
This technique can be implemented efficiently with the help of stack . ie All the turns what you are making in a stack will be pushed inside a stack flags has been used to denote the direction of turn , once if your algorithm unable to proceed with the path then repeatedly pop out the previous positions from the stack and move back to the position and find if any path available , if available get through that path else repeat the pop operation and try to find the new path !
All the best !
Thanks and Regards !
Prince M. Premnath