Recursive and divided treatment

Source: Internet
Author: User

? Very small time, I was very curious, my big celestial \ (13\) million people, census how to find out.

? Then I mended the brain, an ascetic with a booklet in his hand from south to north, from white to black, met a person to draw a positive. Then use feet to measure a wave of national land, statistics of our population.

? This is good enough to explain why the census took so long. Because statisticians count for many years at a time.

? Of course, this is just a joke, the ability of the computer is very powerful.

? The so-called recursion, is the program itself to call themselves to solve their own sub-problems. Some problems in the overall situation can not be directly resolved, but it could be divided into a sub-problem, the continuous division can be from the situation of small sub-problems directly get answers, and then the other way to spell. This kind of thought is called Divide and conquer. The best way for computers to divide and conquer is by recursion.

? For example, the census, calcpeoplecnt (area) to calculate the population of a region. Obviously, the direct get \ (calcpeoplecnt ) is not realistic. So we will be provincial units to carry out the provincial statistics, that is \ (calcpeoplecnt (Hunan) +......\) and so on. Subdivided into city, county, district and so on. Statistics a community or village how many people can hand over to the neighborhood committee directly "violence" to obtain the answer, and then the first level of feedback to synthesize a wide range of answers, then the total number of people in China can quickly come out.

? This "punches, trivial" idea, in \ (oi\) has a great use, about a lot of things will use this kind of thought, so divide and conquer, extremely important.

Recursive and divided treatment

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.