hcysunyang / knowledge Goto Github PK
View Code? Open in Web Editor NEW📗:https://kb.hcysun.me
License: MIT License
📗:https://kb.hcysun.me
License: MIT License
因为insertAfter方法中,新插入的元素next指向下一元素,
将head的next指向自己,会导致最后一个元素的next永远指向head,
这个逻辑就是传说中的"衔尾蛇",
会使链表变为循环链表,从而使得不加终止判断的display方法陷入死循环
display方法修改如下,望修正
// 显示全部节点
display: function () {
var current = this.head
// 加入终止判断,到最后一个元素(next指向head)结束,防止双向链表中发生死循环
while (current.next&¤t.next.data!='head') {
console.log(current.next.data)
current = current.next
}
console.log('======')
}
修改后相关代码如下,在移动current到左右节点之前先判断左右节点是否存在,不存在就直接跳出:
// 查找指定值
find:function(data){
var current=this.root;
while(true){
if(data==current.data){
return current;
}
if(data<current.data){
if(current.left){
current=current.left;
}else{
break;
}
}
if(data>current.data){
if(current.right){
current=current.right;
}else{
break;
}
}
}
return null;
}
另外,英文拼写有误,先序(根)遍历是preOrder traversal,不是perOrder。
还有,除先序遍历,中序遍历,后序遍历以外,
还有按层遍历,按层遍历由于存在先入先出的特性,正好可以利用到之前队列的结构,望补充
基础知识->函数->函数的内部属性
应该是arguments,而不是anguments
点击后提示:「Cannot find resource at /note/」
之前还能访问来着,现在发现地址已经么得了,大佬是服务器到期了吗?还是地址变更了
queue.md
中给出的队列实现中,出队操作在大多数 JS 引擎下是 O(n)
时间复杂度的。而正常的实现应该可以做到 O(1) 或至少均摊 O(1) 的复杂度。
建议把修改这一节的实现;或说明其中的实现仅为数据结构示例,不建议直接使用。
虽关注已久,可惜深入大佬 repo 恨晚。
大佬文章基本 404 了...
新手不会操作,问一哈
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.