标签:反转 int turn 复杂度 nbsp ESS print res 复杂
简述
代码实例
1)字母反转
#递归思想,递归向里面往外扩展呈现出来的也就是从里到外的 def func(str_num): if len(str_num) <1: return str_num return func(str_num[1:])+str_num[0] result = func(str_num) print result
2)快排
#快排算法 ‘‘‘ 快排利用递归思想,进行排序时间复杂度n*log2n def kuaipai(num): if ...: piv = num[0] for i in range(len(num)): if...: elif..: else: more = kuaipai(da) less = kuaiipai(xiao) return more+piv+less ‘‘‘ def kuaipai(num): da,zhong,xiao = [],[],[] if len(num<)<1: return num pivo = num[0] for i in range(len(num)): if i > num[0]: da.append(i) elif i < num[0]: xiao.append(i) else: zhong.append(i) less = kuaiPai(xiao) more = kuaiPai(da) return less+zhong+more
标签:反转 int turn 复杂度 nbsp ESS print res 复杂
原文地址:https://www.cnblogs.com/wangdadada/p/12113296.html