Answer:
1) recursion as an algorithm is widely used in programming language. Refers to the re-entry of functions/procedures/subroutines that invoke themselves directly or indirectly during operation.
2) Recursive algorithms are generally used to solve three types of problems:
A. The definition of the data is defined by recursion. (Fibonacci (Fibonacci) function)
B. The problem solution is implemented by recursive algorithm. Back
C. The structural form of the data is defined recursively. (Traversal of the tree, search of the graph)
3). This is an example of an arrangement in which the work is to sort and output all the elements of a string entered, for example: The parameter you give is "ABC" and the program outputs: ABC ACB BAC BCA Cab CBA A. The exit of the algorithm is: Low=high is now given only one of the permutation elements. B. The approximation process of the algorithm: first determine the first element of the arrangement, that is, the element represented by I in the loop, and then low+1 begin to reduce the permutation element, so continue until Low=high public class Foo {
public static void Main (string[] args) {
Permute ("abc");
}
public static void Permute (String str) {
char[] Strarray = Str.tochararray ();
Permute (strarray, 0, strarray.length–1);
}
public static void Permute (char[] list, int. Low, int.) {
int i;
if (low = = high) {
String cout = "";
for (i = 0; I <= high; i++)
cout + = List[i];
System.out.println (cout);
} else {
for (i = low, I <= high; i++) {
Char temp = List[low];
List[low] = List[i];
List[i] = temp;
Permute (list, low + 1, high);
temp = List[low];
List[low] = List[i];
List[i] = temp;
}
}
}
}
Simple description of what is recursion? What is the use of? and use Java to implement a simple recursive program.