数据结构:有序链表
来源:互联网 发布:淘宝怎么买dota2装备 编辑:程序博客网 时间:2024/05/16 12:01
package none006有序链表;public class SortedListApp {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubSortLinkList slist=new SortLinkList();slist.insert(20);slist.insert(10);slist.displayList();System.out.println();slist.insert(10);slist.insert(30);slist.insert(50);slist.displayList();System.out.println();slist.delete();slist.displayList();}}class Link{int idate;Link next;Link(int value){next=null;idate=value;}public void displayLink(){System.out.print(idate+" ");}}class SortLinkList{Link first;SortLinkList(){first=null;}public void insert(int value){Link previous,current;Link newLink=new Link(value);previous=null;current=first;while(current!=null&¤t.idate<value){previous=current;current=current.next;}if(previous==null){first=newLink;}else{ previous.next=newLink;} newLink.next=current;}public Link delete(){if(first==null)return null;Link temp=first;first=first.next;return temp;}public boolean isEmpty(){return first==null;}public void displayList(){if(first==null){System.out.println("链表已经空了。。");return;}Link current=first;while(current!=null){current.displayLink();current=current.next;}}}
0 0
- 数据结构:有序链表
- 数据结构整理_有序链表合并
- 数据结构之有序链表的归并
- 1465 数据结构:有序链表的合并
- 【数据结构】单链表,双端链表,有序链表
- java数据结构与算法-有序链表
- 数据结构--有序表查找
- 数据结构——将两个有序链表并为一个有序链表算法
- 数据结构 P31 算法实现 有序链表合并为有序链表
- 数据结构-有序链表(基于简单链表)
- 【数据结构】单向有序链表---最水的代码
- 数据结构-用链表函数实现链表的有序合并
- 2119 数据结构实验之链表四:有序链表的归并
- 数据结构实验之链表六:有序链表的建立
- 数据结构实验之链表四:有序链表的归并
- 数据结构实验之链表六:有序链表的建立
- 数据结构实验之链表四:有序链表的归并
- 数据结构实验之链表四:有序链表的归并
- itoa
- 工厂模式(屌丝专用)
- DNS攻击原理与防范
- 网站收藏
- x86 版和x64版有什么区别?
- 数据结构:有序链表
- vc 单文档程序和多文档程序有什么区别?
- c++-域运算符::
- hadoop开始
- C#笔记之ref和out的区别
- ORA-00600: internal error code [kcratr_nab_less_than_odr]
- 测试UDP端口
- 有关MFC单文档多视图的问题
- (LeetCode) Reverse Words in a String