数据结构(C语言)链表.ppt

数据结构(C语言)链表

单链表特点 是一种动态存储结构 指针占用了额外的存储空间 不能随机存取,而是顺序存取 适合做动态操作 带头结点的单链表很多时候可以使算法简化 Combine two Linked chain Two linked chains la lb Their elements are in no-descending order Combine these two chains, Add(la, lb), using the structure of la and lb The result chain’s elements have to be in no-descending order Node add(Node la, Node lb){ Node pa, pb, pc, lc; pa = la.next ; pb = lb.next; pc = la; lc = la; while( pa != null pb!= null){ if(pa.element = pb.element){ pc.next = pa; pc = pa; pa = pa.next; }else{ pc.next = pb; pc = pb; pb = pb.next; } }/*end for while*/ if(pa !=null) pc.n

文档评论(0)

1亿VIP精品文档

相关文档