Let's talk about this mysterious deep search:
A few days ago my heart Daniel told me the deep search feeling is quite simple, but Daniel tell me deep search deep search so you don't know how to search
We also look at the same question: N's full array
For example, the full array of 3
123
213
321
This is the whole arrangement. We use a For loop to do this problem when we don't have a deep search, but if n is big, it's not going to work.
So we're going to have to go deep. In fact, in my opinion, deep search and recursion are brothers deep search is the enhanced version of recursion
I'll write a simple code for the DFS (deep search) function.
#include <stdio.h>intDfsintx) { if(X >N) { for(i =0; I < n;i++) {printf ("%d", B[i]);//B[i] is the number that is recorded in the entire arrangement. return; } } for(i =1; I <= n;i++) { if(A[i].biaozhi)//A[i].biaozhi is to see I used to contin if used.{A[i].biaozhi=1;//1 means to make the Biaozhi 0 when it's initialized.DFS (x +1);//each x represents the number of digits, and if this one is finished, then we'll fill in a place where we can output .A[i].biaozhi =0;//we're going to get the sign back for the next time . } }}
In fact, the meaning of deep search is always looking until you find a qualifying result and then return to the previous DFS to continue looking for
Guangzhou Search:
Daniel told me wide search is a lot easier than deep search, but I feel that I do not really, I would like to tell you the meaning of the broad search is a queue is advanced to the first search after the search
It will be easier to understand this wide search.
Deep Search and wide search