![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
algorithm&datastructure
文章平均质量分 64
xljsskk
这个作者很懒,什么都没留下…
展开
-
algorithm_binarysearch
def binarysearch(A,x): low=0 high=len(A)-1 j=0 i=0 while low<=high and j==0: mid=(low+high)/2 if x==A[mid]: j=mid elif x<A[mid]:原创 2012-12-16 10:45:12 · 312 阅读 · 0 评论 -
algorithm_merge
def merge(A,p,q,r): s=p t=q+1 k=p #s,t are the subarray index,k is B[] index B=[] while s<=q and t<=r: if A[s]<=A[t]: B.append(A[s]) s=s+1原创 2013-01-19 21:31:31 · 409 阅读 · 0 评论 -
algorithm_selectionsort
def selectionsort(A): for i in range(len(A)): #print i,# k=i #print A[i+1:len(A)],# for j in range(i+1,len(A)): if A[j]<A[k]: k=j if k!=i: t=A[i] A[i]=A[k] A[原创 2013-01-19 21:34:45 · 255 阅读 · 0 评论 -
algorithm_prim
def prim(G): dis=0 x=[1] select=G[0] #edge can be selected next time for i in range(len(G)-1): #add n-1 edge for key in select.keys(): #select原创 2012-12-19 10:31:34 · 439 阅读 · 0 评论