摘要:
#!/usr/bin/env python # -*- coding: utf-8 -*- # 快速排序 # 时间复杂度 O(n lgn)-- O(n^2) def quick_sort(array): if len(array) = array[0]]) right = quick_sort([i for i in array[1:] if i < array[0]]) ... 阅读全文
摘要:
#!/usr/bin/env python # -*- coding: utf-8 -*- # 斐波那契数列 def fibonacci_sequence(num): aa = 0 b = 1 li = list() li.append(aa) li.append(b) for i in range(1, num): aa, b... 阅读全文
摘要:
#!/usr/bin/env python # -*- coding: utf-8 -*- # 选择排序 # 时间复杂度O(n^2) def selection_sort(array): length = len(array) for m in range(length): k = 0 for i in range(1, length - m)... 阅读全文
摘要:
#!/usr/bin/env python # -*- coding: utf-8 -*- # 插入排序 # 时间复杂度 O(n^2) import time def logger(func): start_time = time.time() def inner(*args, **kwargs): # 1 return func(*args, **kwa... 阅读全文
摘要:
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 # 冒泡排序法 4 5 6 def bubbling(array): # 时间复杂度:O(n^2) 7 for i in range(0, len(array) - 1): 8 for m in range(i + 1, len(array)): ... 阅读全文