Difference between backtracking and recursion?

前端 未结 7 627
长发绾君心
长发绾君心 2021-01-30 01:47

What is the difference between backtracking and recursion? How is this program working?

void generate_all(int n)
{
    if(n<1) printf("%s\\n", ar);
         


        
7条回答
  •  轮回少年
    2021-01-30 02:32

    In my understanding, backtracking is an algorithm, like all the other algorithms, like BFS and DFS, but recursion and also iteration are methods, they are at a higher level than the algorithms, for example, to implement a DFS, you can use recursion, which is quite intuitive, but you can also use iteration with a stack, or you can also think recursion and iteration are just methods to support your algorithms.

提交回复
热议问题