当前位置:网站首页>Sorting out knowledge points of binarytree and heap
Sorting out knowledge points of binarytree and heap
2022-07-18 07:42:00 【Rong, who has to learn every day】
One 、 Binary tree
Binary tree (Binary tree) Each node most There are only two branches ( That is, there is no branching degree greater than 2 The node of ) The tree structure of the .
Binary trees are also divided into full binary trees , Perfect binary tree , Balanced binary trees .
1、 Full binary tree
A binary tree , If the number of nodes in each layer reaches the maximum , Then the binary tree is Full binary tree . Suppose the number of levels of the binary tree is k
- Sum of nodes of full binary tree :2k - 1
- The maximum number of nodes in each layer :2k-1

2、 Perfect binary tree
In a complete binary tree , Except that the lowest node may not be full , The number of nodes in each layer reaches the maximum , And the nodes of the lowest layer are concentrated in the leftmost positions of the layer . Suppose the number of levels of the binary tree is k
- The number of nodes at the bottom of a complete binary tree ranges from :1 ~ 2k-1-1

3、 Binary search tree
Binary search tree There are values , And it's a Orderly Trees .
- If its left subtree is not empty , Then the value of all nodes in the left subtree is less than the value of its root node ;
- If its right subtree is not empty , Then the value of all nodes in the right subtree is greater than the value of its root node ;
- Its left 、 The right subtree is also a binary sort tree

4、 Balanced binary trees
Balanced binary search tree (AVL Trees ): Balanced binary tree for short . The properties are as follows :
- It can be an empty tree
- If it's not an empty tree , The absolute value of the height difference between its left and right subtrees shall not exceed 1, And both the left and right subtrees are a balanced binary tree .

5、 reference
- Basic theory of binary tree , The species of binary trees 、 Storage 、 Traverse 、 Program definition .
- Trees , Explained the classification of binary tree 、 Storage 、 Traverse .
- What is a balanced binary tree (AVL), Explains why there is a binary balanced tree ,AVL The imbalance and adjustment of tree insertion ,AVL Four ways to insert nodes into a tree ,AVL Four ways to delete nodes in a tree .
Two 、 Pile up
The value of each node in the heap is greater than or equal to ( Or less than or equal to ) The values of all nodes in the subtree . Or say , The value of any node is greater than or equal to ( Or less than or equal to ) Values of all child nodes .
1、 reference
- Pile up , Explained the definition of heap 、 purpose 、 classification 、 Storage 、 operation 、 Sort .
3、 ... and 、 Be careful
1、 Balanced binary search trees (AVL Trees ) Is it right? Binary search tree and Balanced binary trees The combination of ?
Yes , It is the combination of binary search tree and balanced binary tree .
2、 Balanced binary trees And Perfect binary tree The difference lies in the location of the underlying nodes ?
Yes , The bottom layer of a complete binary tree must be continuous from left to right , And the sub bottom is full .
And the balanced binary tree is orderly , There are values , A complete binary tree can have no values .
3、 Pile up yes Perfect binary tree Combination with sorting , instead of Balanced binary search trees ?
Heap approximation can be regarded as a complete binary tree , At the same time, ensure the order of the parent-child nodes ( Orderly ).
The sort of heap is that the parent node is greater than the child node , The parent node of the search tree is larger than the left child , Smaller than the right child , So the heap is not a balanced binary search tree .
边栏推荐
- Record the use of yolov5 (1)
- redHat7.9配置yum源
- Getting started with compilation
- AES encryption learning of openharmony security module
- 实现浏览器 - Servlet - 数据库交互操作
- 模块二interfaces下头文件解析(3)
- Parsing of header files under interfaces in module 2 (3)
- 想到多线程并发就心虚?先来巩固下这些线程基础知识吧!
- 3-6月面经总结,200多页真题笔记和详解(含核心考点及6家大厂)
- 实现一下几个简单的loader
猜你喜欢

mysql中出现Unit mysql.service could not be found 的解决方法

Openharmony related knowledge learning

分库分表真的适合你的系统吗?聊聊分库分表和NewSQL如何选择

Win10 right click the new column to add a new markdown file (typora.md)

Unit MySQL appears in MySQL Solution of service could not be found

根据经纬度计算两点之间的距离

Millimeter wave radar learning (V) -- angle estimation

美团一面面经及详细答案
![[use win10's own remote connection tool] to remotely access and control [another win10 Computer]](/img/a8/c58e43b4e2441db9dc57e1751ee262.png)
[use win10's own remote connection tool] to remotely access and control [another win10 Computer]

Redis+caffeine two-level cache enables smooth access speed
随机推荐
OpenHarmony模块二下文件samgr_server解析(4)
Get to know the three modules of openharmony
Detailed explanation of time complexity and space complexity
Pytorch中torch.max()函数解析
C language: code specification Discussion & excerpts (including excerpts from some rules of [Huawei code specification])
Simple understanding of CAS and AQS
(开源项目)abattoir unity游戏
Redis 分布式锁:从小白到大神方案都经历了什么?
Things about the client (2)
Writing PHP form data to MySQL code
mysql中 decimal(10,2)格式的通过stream 方式写到 kafka 变成 stri
英特尔发布开源AI参考套件
Openharmony module 2 file samgr_ Server parsing (5)
3-6月面经总结,200多页真题笔记和详解(含核心考点及6家大厂)
(open source project) abattoir unity game
Numpy gets a row and a column of a two-dimensional array
实现一下几个简单的loader
Parsing of header file under interfaces in module 2
OpenHarmony模块二interfaces下头文件解析(8)
[brother hero July training] day 15: depth first search