Introduction to the properties of B-Tree

Introduction to the properties of B-Tree

B-tree is a common data structure. Along with him is the B+ tree.

Here, we need to clarify the concept. What is the difference between B-tree, B-tree and B+tree? What is their relationship?

In fact, there are only two types of data structures, namely B-tree and B+ tree. Sometimes, B-tree is also called B-tree, they are the same thing. Note that the "-" in the middle of a B-tree is a hyphen, not a "minus sign". In English, it is B-Tree, which is translated into Chinese as B-tree. Some translators like to include a hyphen “-”, so it becomes B-tree, and B-tree is misread by some readers as B-minus tree.

Before introducing B-tree, let's first look at an important concept: order.

The order of a tree is the maximum number of child nodes of each node in the tree. That is to say, if some nodes have 2 child nodes, some nodes have 4 child nodes, and the maximum number of child nodes is 5, then the order of the tree is 5.

From this perspective, the order of a binary tree is 2.

Next, we introduce the main properties of B-tree. We assume that the order of the B-tree is m. A B-tree of order m is either an empty tree or a tree with the following properties:

1. Each node has at most m child nodes. There are at least m/2 (rounded up) nodes. Or it can be expressed this way: m/2 <= number of child nodes <= m. But the root node is an exception. The root node can have at least 2 child nodes.

2. The number of child nodes of each node is 1 more than the number of keywords stored in the node. That is, when k keywords are stored in a node, the node will have k + 1 child nodes (subtrees).

3. The k keywords in each node are arranged from small to large, and are recorded as k1, k2, k3, ... kk. Then the node will have k+1 pointers, denoted as p0, p1, p2, ... pk. Moreover, all elements in the child nodes pointed to by p3 are greater than k3 and less than k4, as shown in the following figure. This is also relatively easy to understand and remember. Each pointer p is located exactly at the gap between the keyword k. Therefore, the value of the element of the child node pointed to by the pointer at the gap should naturally be greater than the element to the left of the pointer and less than the element to the right of the pointer.

4. B-tree is a strictly balanced search tree, and the heights of its left and right subtrees are equal. The leaf nodes are at the same layer and can be represented by empty nodes.

An example of a B-tree:

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • Differences between MySQL Hash index and B-Tree index
  • Analysis of B-Tree Implementation Details in SQLite
  • How to choose between bitmap index and B-tree index in use
  • Introduction to the B-Tree Insertion Process
  • Based on the use of B-tree and B+ tree: a detailed introduction to data search and database indexing
  • A brief discussion on MySQL B-tree index and index optimization summary
  • Complete B-tree algorithm Java implementation code
  • In-depth understanding of C language B-tree
  • Introduction to the deletion process of B-tree

<<:  Solve the pitfall of storing boolean type values ​​in localstorage

>>:  Vue storage contains a solution for Boolean values

Recommend

Elementui exports data to xlsx and excel tables

Recently, I learned about the Vue project and cam...

HTML table tag tutorial (17): table title vertical alignment attribute VALIGN

The table caption can be placed above or below th...

Detailed explanation of common methods of JavaScript String

Table of contents 1. charAt grammar parameter ind...

SVG button example code based on CSS animation

The specific code is as follows: <a href="...

How to use CocosCreator object pool

Table of contents Preface: Specific operations St...

linux exa command (better file display experience than ls)

Install Follow the README to install The document...

Solve the problem of ugly blue border after adding hyperlink to html image img

HTML img produces an ugly blue border after addin...

Problems and solutions of using jsx syntax in React-vscode

Problem Description After installing the plugin E...

HTML drag and drop function implementation code

Based on Vue The core idea of ​​this function is ...

How to add vim implementation code examples in power shell

1. Go to Vim's official website to download t...

How to use regular expression query in MySql

Regular expressions are often used to search and ...