Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

树、二叉树、二叉搜索树的实现和特性 #45

Open
MaMaFish opened this issue Nov 18, 2021 · 0 comments
Open

树、二叉树、二叉搜索树的实现和特性 #45

MaMaFish opened this issue Nov 18, 2021 · 0 comments

Comments

@MaMaFish
Copy link
Owner

Linked List 就是特殊化的树(有2个 next 指针)
Tree 是特殊化的 Graph(没有环的图就是树)

二叉树遍历

  1. 前序(Pre-order): 根-左-右
  2. 中序(In-order): 左-根-右
  3. 后序(Post-order): 左-右-根
    查询的时间复杂度是 O(n)

二叉搜索树 Binary Search Tree

二叉搜索树,也叫二叉排序树、有序二叉树、排序二叉树,是指一刻空树或者具有下列性质的二叉树:

  1. 左子树上所有节点的值均小于它的根节点的值
  2. 右子树上所有节点的值均大于它的根节点的值
  3. 以此类推:左、右子树也分别为二叉查询树

中序遍历:升序排列
插入和操作的时间复杂度都是 O(logn)

@MaMaFish MaMaFish changed the title 树、二叉树、二叉搜索树的实现和特性.md 树、二叉树、二叉搜索树的实现和特性 Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant