Count Sort----Giveaway 1

Source: Internet
Author: User

Problem Solving Ideas:

Cases:

Program:

Import TimeImportRandomdefCal_time (func):#adorner, used to detect the time the algorithm executes    defWrapper (*args,**Kwargs): T1=time.time () result=func (*args,**Kwargs) T2=time.time ()Print("%s Running time:%s secs."% (func.__name__, t2-t1)) returnresultreturnWrapper@cal_timedefCount_sort (li,max_num): Count= [0 forIinchRange (Max_num + 1)]#from 0 ~ max_num     forNuminchLi#Traverse LiCount[num] + = 1#if the number of Li appears once, then increase the number of indexes by 1i =0 forNum,minchEnumerate (count):#Enumerate: Index + value num is the number of index number M         forJinchRange (m): Li[i]=num I+ = 1Data= [] forIinchRange (100000): Data.append (random.randint (0,100))#both before and after Randint includeCount_sort (data,100)Print(data)

The running result of the program is:

``````````````

Count Sort----Giveaway 1

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.