python-recursive function

Source: Internet
Author: User

Default recursion Maximum 1000
Do not modify the default recursive maximum
Often recursion is linked to the loop.
People understand loops, God understands recursion
Algorithm
recognize recursion
How does the recursive function read?
examples
Algorithm: A method of computation
Typical problems: bubble sort, quick sort, heap sort
Binary search: Find 58 of the examples below
Two-point search
defFind_2 (l,aim,start=0,end=None):ifEnd = = None:end = Len (l)-1ifEnd >=Start:mid= (End-start)//2 +StartifL[mid] >Aim:ret= Find_2 (l,aim,start,mid-1)            returnretelifL[mid] <Aim:ret= Find_2 (l,aim,mid+1, end)returnretElse:returnAim,midElse :        Print('no content found') Find_2 (L,58)

Calculation of factorial
What is factorial: 7*6*5*4*3*2*1
Calculation of factorial
Fibonacci sequence
Fibonacci

Level three Menu
Level three Menu
menu = {    'Beijing': {        'Haidian': {            'Five crossing': {                'Soho': {},                'NetEase': {},                'Google': {}            },            'Zhongguancun': {                'Iqiyi Art': {},                'Autohome': {},                'Youku': {},            },            'on the ground': {                'Baidu': {},            },        },        'changping': {            'Shahe': {                'old boy': {},                'Beihang University': {},            },            'Tin Tong Court': {},            'Huilongguan': {},        },        'Chaoyang': {},        'Dongcheng': {},    },    'Shanghai': {        'Minhang': {            "People's square": {                'Fried Chicken Shop': {}            }        },        'Zhabei': {            'Train Warfare': {                'Ctrip': {}            }        },        'Pudong': {},    },    'Shandong': {},}defmenu_3 (menu): whileTrue: forKeyinchMenu:Print(key) Choice= Input ('Choice:')        ifChoice = ='Q' orChoice = ='b':            returnChoiceifChoiceinchMenu andMenu[choice]: Borq=menu_3 (Menu[choice])ifBorq = ='Q':return 'Q'menu_3 (menu)

python-recursive function

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.