function quick_sort(s, _begin, _end) if _begin < _end then i = _begin j = _end pivot = s[j] while i < j do while(i < j and s[i] <= pivot) do i = i + 1 end if i < j then s[j] = s[i] end while(i = pivot) do j = j - 1 end if i < j the
本文分享的实例主要是Python编程二分法实现冒泡算法+快速排序,具体如下。
冒泡算法:
#-*- coding: UTF-8 -*-
#冒泡排序
def func(lt):
if type(lt).__name__ !='list' and type(lt).__name__ !='tuple':
return
if type(lt).__name__ == 'tuple':
return list(lt)
for i in range(1,len(lt)-1):
for j in r