排序算法有很多,目前最好的是quick_sort:unstable,spatial complexity is nlogN.
快速排序原理
python实现
严蔚敏的 datastruct书中有伪代码实现,因为Amazon面试需要排序,所以用python实现了。
两种实现方法,功能一致,效率没测,请高手留言
第一种实现
标准算法,严蔚敏书中的伪代码实现
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
@author: willard
'''
def quick_sort_standord(array,low,high):
''' realize from book "data struct" of author 严蔚敏
'''
if low < high:
key_in