JAVA recursive data structures and algorithms 6

Recursive: calls itself directly or indirectly. For example the number of consecutive factorial calculation, the calculation law:! N = (n-1) * n!.

Each recursive method has a base value (termination) conditions to prevent recursion wirelessly, and the consequent crash.

Recursive because it simplifies the problem conceptually, recursive algorithm structure clear, readable and easily using mathematical induction to prove algorithm correctness. However, it takes time and space to spend more than non-recursive algorithm.

About recursive and divide and conquer:

The basic idea is to divide and conquer a scale problem is decomposed into k n a smaller sub-problems, these sub-problems with the original problem and the same independent of each other.

Solution of these sub-problems recursively , then the de-merger of each sub-problem to get solution of the original problem.

Uses divide and conquer algorithm is generally thought to design a recursive algorithm, so the time complexity of divide and conquer the problem can also be used to analyze a recursive equation .

 

Recursion and backtracking on:

Backtracking algorithm is also an idea, you can use recursive implementation. Popular speak back it is a kind of test, similar to the exhaustion, but back there "pruning" function.

 

Guess you like

Origin www.cnblogs.com/lsh0908/p/11770783.html
Recommended