In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what recursion is, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
The programming skill in which a program calls itself is called recursion.
As an algorithm, recursion is widely used in programming languages. A process or function has a method of calling itself directly or indirectly in its definition or description, which usually transforms a large and complex problem into a smaller problem similar to the original problem. The recursive strategy requires only a small number of programs to describe the repeated calculations needed in the problem-solving process, which greatly reduces the amount of code of the program. The ability of recursion lies in defining an infinite set of objects with finite statements.
Generally speaking, recursion requires boundary conditions, recursive forward segments, and recursive return segments. When the boundary condition is not satisfied, the recursive forward; when the boundary condition is satisfied, the recursive return.
Example of a function nested call procedure
To constitute the conditions required for recursion:
1. The sub-problem must be the same thing as the original problem and simpler.
two。 Cannot call itself indefinitely, there must be an exit, which can be reduced to non-recursive processing.
In mathematics and computer science, recursion refers to a class of objects or methods defined by one (or more) simple basic cases and specifies that all other cases can be restored to their basic cases.
In mathematics and computer science, recursion refers to a class of objects or methods defined by one (or more) simple basic cases and specifies that all other cases can be restored to their basic cases.
For example, the following is a recursive definition of someone's ancestor: someone's parents are his ancestors (basic case).
The parents of one's ancestors are also one's ancestors (recursive steps). The Fibonacci series (Fibonacci Sequence), also known as the golden section series, refers to such a series: 1, 1, 2, 3, 5, 8, 13, 21. I [1]
Fibonacci series is a typical recursive case: a recursive relationship is a relationship between an entity and itself.
Fib (0) = 1 [basic case] Fib (1) = 1 [basic case] for all integers with n > 1: Fib (n) = (Fib (n Mel 1) + Fib (n Mel 2)) [Recursive definition] although there are many mathematical functions that can be expressed recursively, in practical applications, the high cost of recursive definition is often prohibitive. For example:
Factorial (1) = 1 [basic case] for all integers n > 1: factorial (n) = (n * factorial (nmur1)) [recursive definition] is an easy-to-understand psychological model, which holds that the recursive definition of objects is defined according to "previously defined" similar objects. For example, how can you move 100 boxes? Answer: you first move a box and write down where it is moving, and then solve the smaller problem: how can you move 99 boxes? Eventually, your question will become how to move a box, and you already know what to do.
Such a definition is very common in mathematics. For example, the formal definition of a natural number in set theory is: 1 is a natural number, and each natural number has a successor, which is also a natural number.
Drost effect
Drost effect is a visual form of recursion. Among the objects held by the woman in the picture is a small picture of herself holding the same object, and then a smaller picture of her holding the same object, and so on.
For example, if we put a burning candle between two opposite mirrors, we will see a candle in one of the mirrors, another mirror behind the candle, and another candle in the mirror. This is also a sign of recursion.
So much for sharing about what recursion is. I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.