惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Proofpoint News Feed
G
GRAHAM CLULEY
P
Privacy International News Feed
The Hacker News
The Hacker News
Forbes - Security
Forbes - Security
U
Unit 42
N
News and Events Feed by Topic
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Cisco Blogs
A
About on SuperTechFans
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
D
Docker
I
Intezer
Spread Privacy
Spread Privacy
The Last Watchdog
The Last Watchdog
V2EX - 技术
V2EX - 技术
S
Security @ Cisco Blogs
F
Full Disclosure
S
Secure Thoughts
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
W
WeLiveSecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Project Zero
Project Zero
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
S
Security Affairs
AWS News Blog
AWS News Blog
H
Help Net Security
The GitHub Blog
The GitHub Blog
Hacker News: Ask HN
Hacker News: Ask HN
Vercel News
Vercel News
P
Proofpoint News Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The Register - Security
The Register - Security
S
Schneier on Security
F
Fortinet All Blogs
C
CERT Recently Published Vulnerability Notes
L
LINUX DO - 最新话题
T
Tor Project blog
T
The Exploit Database - CXSecurity.com
MongoDB | Blog
MongoDB | Blog
Webroot Blog
Webroot Blog

vzard's blog

跳表 - vzard's blog redis的事务 - vzard's blog redis数据类型及使用场景 - vzard's blog 二叉树非递归遍历统一写法 - vzard's blog 灵魂七问 - vzard's blog XPath线索追踪技术 - vzard's blog cron表达式小记 - vzard's blog 计算广告核心问题总结 - vzard's blog 实现一个简单的http服务器 - vzard's blog 由三次握手想到的... - vzard's blog Js原型链解读 - vzard's blog 统计知识(1) - vzard's blog 同步Github上的fork - vzard's blog Http协议杂谈 - vzard's blog JAVA虚拟机的类加载机制 - vzard's blog HashMap源码剖析 - vzard's blog Java中的锁 - vzard's blog 关于volatile - vzard's blog 修复hexo博客的一个bug - vzard's blog
二叉搜索树的一些性质 - vzard's blog
vzardlloo · 2020-09-22 · via vzard's blog

二叉搜索树的中序遍历的结果序列是一个递增排序的序列。

中序遍历的顺序是:左节点 - 根节点 - 右节点

示例代码:

1
2
3
4
5
6
7
8
9
10
11
12
result := make([]*Node,0)
func inorder(root *Node) {
if root == nil {
return
}

inorder(root.Left)
result = append(result,root)
inorder(root.Right)

return
}

二叉搜索树的后继节点

即比当前节点大的最小节点,主要思路:取改节点的右节点,然后一直取左节点直到左节点为空,最后指向的就是该节点的后继节点

示例代码:

1
2
3
4
5
6
7
func Successor(node *Node) *Node {
succ := node.Right
for succ.Left != nil {
succ = node.Left
}
return succ
}

二叉搜索树的前驱节点

即比当前节点小的最大节点,主要思路:取改节点的左节点,然后一直取右节点直到右节点为空,最后指向的就是该节点的前驱节点

示例代码:

1
2
3
4
5
6
7
func Predecessor(node *Node) *Node {
pre := node.Left
for pre.Right != nil {
pre = pre.Right
}
return pre
}