Solved

Non-recursive backtracking, using a stack

Posted on 2016-10-26
1
307 Views
Last Modified: 2016-11-08
Hi,

I was going through below link

http://www.cis.upenn.edu/~matuszek/cit594-2012/Pages/backtracking.html

what is difference between
Non-recursive backtracking, using a stack and
Non-recursive backtracking without using a stack

what is difference between
Non-recursive backtracking and recursive backtracking
please advise
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
James Bilous earned 500 total points
ID: 41860708
When you make recursive calls you are using a naturally occuring memory "call stack". This call stack is simply how your machine keeps track of functions that were previously called so that when you return, you can be placed back into the function where you left off. When you are using recursion to search a tree, you can exploit this naturally occuring stack to backtrack. Each recursive call to your function essentially keeps track of a single visit to a node in your tree.

When you don't use recursion, you have to use your own data structure called a Stack to emulate this behavior. The stack data structure will keep tabs of each node you visit rather than your function calls doing this for you in a recursive implementation.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What browser will run Java? 7 171
Drop down list show all elements but disabled for selection 6 60
Java array 10 86
Extract data from output with RegEx 1 41
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question