"Inception" and recursion in the program

Source: Internet
Author: User

The dream does not know the body is a guest, a noon greedy huan.
----Li Yu "Surf the Sand"
This life wrong train, destined not to be with you,
A dream dream, my soul, chasing you to the afterlife ...
----a Taiwanese poetess.

Saw the inception of the Dream space. Inception English name literal translation is "establishment" meaning.

The hero can enter your dream, change your subconscious in the dream. This is the greatest danger is not clear which is the dream, which is the reality.

In reality, we often encounter such a situation, to their own bite to see whether it will hurt, or will not wake up.

The place where the audience is confused in the dream of inception is the dream. In your dreams, you can dream again.
There are similar concepts in computers. For example, recursion is the most typical application.

the so-called recursive-recursive is that you can call yourself in the method.

The following is one of the simplest recursion (of course it will be a dead loop, so the real recursion does not write this)

public void Sayhi () {
System.out.println ("hello!");
Sayhi (); Himself to call itself, would be called countless times
}
The above program, if you run, will eventually stackoverflow the stack overflow error.

One of the true recursive applications: to find the factorial of a number
public int fact (int n) {

if (n>0)
Return N*fact (n-1);
Else
return 1;
}

If the argument is 4, its call order is shown in Figure 1 below:


Figure 1-Recursive call sketch

There are a number of examples of recursive invocations, such as Hanrotta problems and so on.

Hehe by the way, if you do not understand the inception of the space, then do not engage in software. Technorati Tags: Atixujie, java, PENGZJ, inception space, inception

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.