自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(11)
  • 收藏
  • 关注

原创 算法导论 - 11 - Dynamic Programming

伪代码1.//given a rod (length = n) and price i("pi" ,i =1,...,n)//r[i] : the maximum value of a rod (whose length = n) , initialize to be -INFmemoized-cut-rod(p,n,r)for i=1 to n    r[i]=-INFreturn memoiz...

2018-07-07 21:01:56 301

原创 算法导论 - 10 - Dijkstra、Bellman-Ford、Bi-Directional search

伪代码1.initialize(G,s)for v in G    v.d=INFs.d=02.relax(u,v,w)if v.d>u.d+w(u,v)    v.d=u.d+w(u,v)3.min-heapify(Q,i)m=Q.lengthif 2*i<=m    if Q[i].d>Q[2*i].d        smallest=2*i    else        s...

2018-07-06 15:46:06 388

原创 算法导论 - 9 - BFS 、DFS、Topological sort

伪代码1.BFS(x)s=new queues.push(x)while !s.empty()    u=s.front    s.pop    u.visit=true    for v has edge(u,v)        if !v.visit // !!!only put not-visit node into queue            s.push(v)2.DFS(G) //...

2018-07-06 00:23:55 267

原创 算法导论 - 8 - Direct address、Chain hash、Open addressing hash

伪代码/** * following are for direct-address**/1.direct-address-search(T,k)    return T[k]2.direct-address-insert(T,x)    T[x.key]=x3.direct-address-delete(T,x)    T[x.key]=NULL/** * following are for ha...

2018-07-05 20:53:44 384

原创 算法导论 - 7 - Bucket sort

伪代码1.//bucketsize is up to the maximum number in ABucket-sort(A,bucketsize)B[0,...,bucketsize-1]=new node Arrayfor i=0 to bucketsize-1    B[i]=new nodefor i=0 to A.length-1    index=|_A[i]/10_|    if ...

2018-07-04 22:37:43 182

原创 算法导论 - 6 - Counting sort、Radix sort

伪代码1.Counting sort(A,B,k)//numbers in A vary from 0 to k , A[1,...,n] , B[1,...,n]//B is required for producing a sorted arrayC[0,..,k]=new array for i=0 to k    C[i]=0for i=1 to n // n=A.length    C[...

2018-07-04 21:45:41 201

原创 算法导论 - 5 - Red-Black Tree

性质(5个)每个结点不是红色就是黑色根结点黑色每个叶子结点(NIL)黑色每个红色结点有两个黑色的子结点每个结点到其后代所有叶子结点的 简单路径 上,包含相同数目的黑色结点伪代码1.left-rotate(T,x) //x.right!=NULL//when connecting parent and child, first set parent -> child (parent.l/r=c...

2018-07-04 21:03:50 184

原创 算法导论 - 4 - Binary Search Tree

伪代码/** *following are three ways to walk through BST**/1.preorder-tree-walk(x)// remember to check whether x is nullif(x!=NULL)    print x.key    preorder-tree-walk(x.left)    preorder-tree-walk(x.rig...

2018-07-03 15:06:59 161

原创 算法导论 - 3 - Heap sort (数组)

伪代码1.max-heapify(A,i)//assume left and right both are max heap//pay attention to field 'i' , remember itl=2*ir=2*i+1if l<=A.heap-size and A[i]<A[l]  // l must be within A's scope     largest=lel...

2018-07-02 22:01:30 304

原创 算法导论 - 2 - Merge sort

伪代码1.merge-sort(A,p,r)    if(r-p>1)        q=p+(r-p)/2        merge-sort(A,p,q+1)        merge-sort(A,q+1,r)        merge(A,p,q+1,r)2.merge(A,p,q,r)n1=q-pn2=r-qL[0,...,n1]=new arrayR[0,...,n2]=new ...

2018-07-02 20:24:48 246

原创 算法导论 - 1 - Insertion sort

伪代码1.insertion-sort(A)for j=1 to A.length-1    key=A[j]    //insert A[j] into sorted sequence A[0,...,j-2]    i=j-1    while(i>=0&&A[i]>key)        A[i+1]=A[i]        i=i-1    A[i+1]=key...

2018-07-02 19:36:04 258

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除