随笔分类 -  algorithms

摘要:1 import random 2 3 def partition(A, lo, hi): 4 pivot_index = random.randint(lo, hi) 5 pivot = A[pivot_index] 6 A[pivot_index], A[hi] = ... 阅读全文
posted @ 2015-02-26 14:18 Justin.cn 阅读(235) 评论(0) 推荐(0)
摘要:An Python implementation of heap-sortbased on the detailed algorithm description in Introduction to Algorithms Third Editionimport randomdef max_heap... 阅读全文
posted @ 2015-02-25 21:54 Justin.cn 阅读(250) 评论(0) 推荐(0)