0
点赞
收藏
分享

微信扫一扫

数据结构55-append方法实现代码


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>双向链表</title>
</head>
<body>
<script>
function doubleList(){
this.head=null
this.tail=null
this.length=0

function Node(data){
this.data=data
this.prev=null
this.next=null
}

linkedList.prototype.append=function(data){
var newNode=new Node(data)
if(this.length==0){

this.head=newNode
}else{

var current=this.head
while(current.next){
current=current.next
}
current.next=newNode
}
this.length+=1
}

}
</script>
</body>
</html>

举报

相关推荐

0 条评论