数据结构 链表
来源:互联网 发布:sql server 2005 补丁 编辑:程序博客网 时间:2024/06/07 01:38
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <scripttype="text/javascript"> functionNode(elemnt) { this.item= elemnt; this.next= null; } //循环列表需要修改一下构造函数,和遍历时候的判断条件 //构造函数如下;希望从后向前遍历,又不想要建立双向链表,就使用循环链表。 functionLlist() { this.head= new Node("1"); this.head.next= this.head; this.remove= remove; this.insert= insert; this.find= find; this.display= display; //.......... } functionfind(number) { var curr= this.head; while (curr.item!= number) { curr = curr.next; } return curr; } functioninsert(element,newElement) { var preNode= this.find(element); var current= new Node(newElement); current.next= preNode.next; preNode.next= current; } functionremove() { var current= this.head; console.log("remove"); var hh= 0; while (current.next.next!= null && current.item != current.next.next.item) { var temp= current.next.next; current.next.next= temp.next; current = temp.next; temp.next= null; } return current; } functiondisplay(flag,current) { var crr= this.head; // if (flag) { while(crr.next.item!="1"){ console.log(crr.item); crr = crr.next; } } else {//最后只剩两个直接输出 console.log(current.item); console.log(current.next.item); } } var Clist= new Llist(); for (var i= 1; i < 41; i++) { Clist.insert(i.toString(), (i+ 1).toString()); } Clist.display(1,null); Clist.display(0,Clist.remove()); </script> </head> <body> </body> </html>
0 0
- 数据结构---链表
- 数据结构 - 链表
- 【数据结构】链表
- 数据结构-链表
- '数据结构' 链表
- 数据结构-链表
- 【数据结构】链表
- 数据结构--链表
- 【数据结构】 链表
- 数据结构--链表
- 数据结构-链表
- 数据结构 - 链表
- 链表 - 数据结构
- 数据结构:链表
- [数据结构]链表
- 数据结构--链表
- 【数据结构】链表
- 数据结构-链表
- C语言类型修饰符总结
- SQL语句基础1-基本概念
- Parallel Python 并行计算
- eclipse通过源码集成SVN插件
- 设计模式之六大原则——接口隔离原则(ISP)
- 数据结构 链表
- (4.3.2.5)EditText限制输入字符类型的几种方式
- 苹果系统自带滑动返回功能
- 高尔夫距离精度数据拟合——梯度下降法详解
- 为什么明明安装了这个Android应用,却找不到
- 你知道老司机吗,这里带你飘逸
- [知其然不知其所以然-22] What's inside the pm_trace
- html5 在Android 开发中的应用
- C语言位运算总结