-
递归
场景:
1)斐波那契数列
-
递推
场景:
1)斐波那契数列
2)递归 + 回溯
-
栈
先进后出
场景:
1)path.resolve /a/b/…/c/d —> /a/c/d
2)JSX
3)加减乘除表达式(2*3)+ 4
4)函数嵌套,函数调用栈
-
队列
先进先出
-
链表
- 动态数据结构
- 单向链表
- 双向链表
- 反转链表
- 环形链表
- 跳表
// 节点 class Node{ constructor(elment){ this.element = element; this.next = null; } } // 链表 class LinkNodeList{ constructor(){ this.head = null; this.length = 0; } // 增加节点 append(element){ let node = new Node(element); let cur; // 两种情况:1.链表为空 2.链表不为空 if(this.head == null){ this.head = node; } else{ cur = this.head; while(cur){ cur = cur.next; } cur.next = node; this.length += 1; } } // 删除 removeAt(index){ let cur = this.head; let prev; let i; if(index == 0){ this.head = cur.next; cur.next = null; } else { while(i<index){ prev = cur; cur = cur.next; i++; } prev = cur.next; cur.next = null; } } // 打印链表 print(){ let cur = this.head; let result = []; while(cur){ result.push(cur.element); cur = cur.next; } return result; } }
-
数组
- 连续存储
- 删除、新增复杂度比较高
-
树
-
二叉树
-
二叉树的三种遍历
1)前序遍历(根节点->左节点->右节点)
2)中序遍历(左节点->根节点->右节点)
3)后序遍历(左节点->右节点->根节点)
-
二叉搜索树
性质:
-
若左子树不为空,则左子树上所有节点的值都小于根节点的值
-
若右子树不为空,则右子树上所有节点的值都大于根节点的值
-
左右子树也分别为二叉搜索树
-
中序遍历,为递增有序列表
-
-
-
图
-
react中的fiber和虚拟dom
-
二分法
-
位运算
-
按位与:&
示例:(5&1相当于余于2)
101 // 5 101 // 5 001 // 1 010 // 2 001 // 1 000 // 0
-
按位或:|
-
按位异或:^
-
按位取反:~
-
按位移:>>左移;<<右移
示例:(5>>1相当于除于2,5<<1相当于乘于2,)
5>>1 // 2 5<<1 // 10
-
09-20
6万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交