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

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - ChuckLu

英语背单词 专八词汇 中英对照 2026年05月 背单词 纯英文 2026年05月 - ChuckLu 英语背单词 专八词汇 中英对照 2026年04月 背单词 纯英文 2026年04月 英语背单词 专八词汇 中英对照 2026年03月 背单词 纯英文 2026年03月 背单词 纯英文 2026年02月 英语背单词 专八词汇 中英对照 2026年02月 英语背单词 专八词汇 中英对照 2026年01月 背单词 纯英文 2026年01月 英语背单词 专八词汇 中英对照 2025年12月 背单词 纯英文 2025年12月 二叉树 节点的个数关系 补码加减法 英语背单词 专八词汇 中英对照 2025年11月 背单词 纯英文 2025年11月 KMP算法 图 生成树 图论 Walks Trails and Paths 英语背单词 专八词汇 中英对照 2025年10月 背单词 纯英文 2025年10月
二叉树 遍历
ChuckLu · 2025-11-23 · via 博客园 - ChuckLu

已知一棵二叉树的前序遍历为ABDFCE,中序遍历为DFBACE,则后序遍历为?

前序遍历是A开头,所以A是根节点

中序遍历A左边的DFB是A左侧的,CE是A右侧的

前序遍历的时候,DFB的顺序是BDF,所以B第二层是根节点,也是A的左侧子节点

前序遍历的时候,CE的顺序是CE,所以C是第二层的根节点,也是A的右侧子节点

因为中序遍历的时候是DFB,而B是父节点。所以DF是B的左侧部分的节点。B左侧只有一个节点,所以DF必然是分布在两层

因为中序遍历的时候是CE,而C是父节点,所以E是右侧的节点

二叉树的遍历方式有三种常见类型:前序遍历、中序遍历和后序遍历。它们的顺序如下:

  1. 前序遍历(Preorder Traversal)

    • 访问顺序:根节点 → 左子树 → 右子树

    • 操作步骤:先访问根节点,然后递归访问左子树,最后递归访问右子树。

    • 例子:对于树结构:

          A
         / \
        B   C
       / \
      D   E

      前序遍历的结果是:A B D E C

ABC

ABDEC

  1. 中序遍历(Inorder Traversal)

    • 访问顺序:左子树 → 根节点 → 右子树

    • 操作步骤:先递归访问左子树,再访问根节点,最后递归访问右子树。

    • 例子:对于上述树结构,中序遍历的结果是:D B E A C

BAC

DBEACB

  1. 后序遍历(Postorder Traversal)

    • 访问顺序:左子树 → 右子树 → 根节点

    • 操作步骤:先递归访问左子树,再递归访问右子树,最后访问根节点。

    • 例子:对于上述树结构,后序遍历的结果是:D E B C A

BCA

DEBCA

这些遍历方式在实际应用中,通常用于树的递归操作、表达式求值、文件系统遍历等场景。