BinaryTree

这篇博客概述了二叉树的各种类型,包括Binary Tree、Binary Search Tree、Complete Binary Tree、Balanced Binary Tree,特别讨论了AVL树和Red Black Tree。博主强调了这些树的数据结构特性,并提及了在LeetCode上的相关问题,如检查是否为平衡二叉树。此外,还提到了树的遍历方法和节点操作,以及资料来源。

Binary Tree

前排提示

  • 中英文混写
  • 基础复习
  • 目标读者:我自己(复习用)

罗列一下各种树, 这个链接总结的特别好,我自己再总结一下加深印象

Binary Tree

A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child.
source: https://www.pdai.tech/md/algorithm/alg-basic-tree.html

Binary Search Tree

Binary Search Tree is a node-based binary tree data structure which has the following properties:

  • The left subtree of a node contains only nodes with keys lesser than the node’s key.
  • The right subtree of a node contains only nodes with keys greater than the node’s key.
  • The left and right subtree each must also be a binary search tree.
  • There must be no duplicate nodes.
    source: geeks for geeks

Complete Binary Tree

A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible.
在这里插入图片描述
Special case: full binary tree, which is completely filled, even the last level

Balanced Binary Tree

A Balanced Binary Tree is a binary tree that full-fills all following requirements.

  • The left and right subtrees’ heights differ by at most one
  • The left subtree is balanced
  • The right subtree is balanced

AVL

Typical self-balancing BST

Red Black Tree

Another typical self-balancing BST.
Rules for red black tree:

  • Every node has a color either red or black.
  • Root of tree is always black.
  • There are no two adjacent red nodes (A red node cannot have a red parent or red child).
    在这里插入图片描述
    划重点
  • Why red black tree?
  • red black tree vs AVL
  • How to implement?
    必看1
    必看2

B+/B-

还没学到。回头再更。我们专业database居然是选修课,专业选的好,自学学到老

FAQ

Leetcode (待更)

110 Balanced binary tree

  • return true if it’s balanced, otherwise return false
  • recursion (bottom up/ top down)
  • recall what’s balanced binary tree
    • The left and right subtrees’ heights differ by at most one
    • The left subtree is balanced
    • The right subtree is balanced

References

JAVA知识全栈体系
Geeks for Geeks
Wikipedia
leetcode
Tech Interview Prep List

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值