当前位置:网站首页>Application, addition and deletion of B-tree
Application, addition and deletion of B-tree
2022-07-27 03:43:00 【Aries_ Ro】
B- Trees
B- The application of tree 
B- Trees are suitable for Disk storage Application .
Because disk operation is compared with CPU Reading operation is time-consuming , and B- Compared with binary tree , There are fewer searches , More efficient .
Use an example to illustrate :
If there is 1024 Data , If stored in binary tree , There will be 10 The height of the tree of the layer . Retrieving data from the root node to the leaf node requires multiple data comparison operations . In disk operation, the next node to find after each comparison is disk addressing . If If the level is higher , Will look for many times . relatively speaking B- The addressing times of the tree will be much less .( Because a node contains multiple key value , In general, it will reduce the height of the tree ).
B- The characteristics of the tree
One M rank B- Trees , The following conditions are met (M Order refers to the B- Trees are M Fork tree ):
1. Each node has at most M A daughter tree
2. The root node has at least two subtrees
3. Except for the root node , Each of the remaining branch nodes has at least M/2 A daughter tree
4. All the leaf nodes are on the same layer
5. Yes k The branch nodes of the subtree exist k-1 Key words , Keywords are sorted in ascending order
6. Outside the root node , The number of keywords meets ceil(M/2)-1 <= n <= M-1
Analyze these conditions :
This is a picture of 6 rank B- Trees

Conditions 1: such as (0012 0016 0022 0025 0028) This node , At most, you can only connect 6 Under the root line ;
Conditions 2 It's easy to understand
Conditions 3: Each branch node must have 3 And more than trees
Conditions 4: Leaf nodes are on the first floor , Maintain absolute balance .
Conditions 5: such as (0003 0006) This node has 2 Key words , It has 3 Subtree . Because there are three ranges , Corresponding to three subtrees . for example {x < 0003; 0003 < x < 0006; x > 0006} Three ranges .
Conditions 6: This 6 rank B- In the tree , The number of keywords meets 2≤n≤5.
Satisfy this 6 One condition is B- Trees .
B- Tree operation
Adding values
B- Adding values to a tree involves split operation . Because when the number of key words added to a node is equal to the order , It will be satisfied by splitting B- Properties of trees .
Or to 6 rank B- Trees, for example :
from (0001 0002 0003 0004 0005) Add 0006 keyword ,
When the node exceeds 5 individual key When the value of , Will perform split operation .
Value deletion
B- The deletion of values in the tree involves Consolidation and borrowing operation .
With 6 rank B- Trees, for example :
Merge operation
Delete 0001 keyword ,

Due to deletion 0001 after , This node has only 0002 A keyword , Not meeting the conditions 6, Therefore, it is necessary to merge .
Borrow operation
Delete 0002 keyword ,

Due to deletion 0002 after , This node has only 0003 A keyword , At this time, borrow the root node 0006, take 0007 Upgrade to root node .
边栏推荐
- [tree chain dissection] 2022 Hangzhou Electric Multi school 21001 static query on tree
- 数字孪生应用及意义对电力的主要作用,概念价值。
- 768. 最多能完成排序的块 II 贪心
- Network security / penetration testing tool awvs14.9 download / tutorial / installation tutorial
- Characteristics and experimental suggestions of abbkine abfluor 488 cell apoptosis detection kit
- Mysql: summary of common sub database and sub table schemes of Internet companies
- 768. Block II greed that can complete sorting at most
- Redis源码学习(33),命令执行过程
- Six determination methods of Worthington peroxidase activity
- mysql底层数据结构
猜你喜欢

Digital analog 1232

Code practice when the queue reaches the maximum length

Graphic SQL, this is too vivid!

客户端发送一条sql如何与服务器交互

MySQL中文失败问题

Kettle读取按行分割的文件

复盘:DFS与BFS的主要区别,在思想上的区别,代码实现上的区别

Spark: calculate the average value of the same key in different partitions (entry level - simple implementation)

Spark Learning Notes (VI) -- spark core core programming RDD action operator

How to optimize MySQL
随机推荐
若依框架代码生成详解
Banyan data model of Bairong
Tool class of localdatetime sorted out by yourself
Binary tree (day 82)
flask_ Reqparse parser inheritance in restful
connman介绍
30 minutes to thoroughly understand the synchronized lock upgrade process
mysql底层数据结构
百融榕树数据模型
阿里 Seata 新版本终于解决了 TCC 模式的幂等、悬挂和空回滚问题
Fastboot刷机
[understanding of opportunity -52]: the depth of communication varies from person to person
代码回滚,你真的理解吗?
Kettle读取按行分割的文件
docker 创建mysql 8.x容器,支持mac ,arm架构芯片
Characteristics and determination scheme of Worthington pectinase
Characteristics and experimental suggestions of abbkine abfluor 488 cell apoptosis detection kit
Reading notes of Kazuo Inamori's advice to young people
shell awk
768. 最多能完成排序的块 II 贪心