[soft test] data structure - tree structure - B tree and B + tree

1. Introduction to B-Tree

1.1 What is B-Tree?

B-Tree (B-Tree) is a commonly used, efficient, self-balancing tree data structure
B-Tree (B-Tree) is a balanced search tree
B-Tree (B-Tree) is a multi-way search tree

1.2 The use of B-Tree (B-Tree)

B-Tree (B-Tree) is suitable for external storage
B-Tree (B-Tree) is mainly used for disk storage and file system
B-Tree (B-Tree) can efficiently perform file indexing and database indexing.
B-Tree can be used to efficiently store and retrieve large amounts of data on disk.
B-Tree (B-Tree) is suitable for scenarios that need to store actual data

1.3 Internal structure of B-Tree

Each node of the B tree can store multiple elements, and the insertion and deletion operations are faster

  • Internal nodes can hold the actual data
  • Internal nodes hold keywords and pointers to child nodes,
  • Leaf nodes hold keywords and pointers to data nodes
  • Each leaf node holds data and a pointer to the next leaf node.
  • Each node holds a pointer to the next leaf node
  • Each node can hold multiple keywords and pointers
  • Each node contains a list of pointers to its child nodes, and a pointer to its associated element.
  • Each node can have multiple child nodes, and each node can store multiple elements,
  • The number of child nodes of each node is fixed, usually M (M is a larger integer, such as M=16)

1.4 Advantages of B-Tree

There is no need to rotate nodes when inserting and deleting elements, so insertion and deletion operations are faster.

2. Introduction to B+ Tree

2.1 What is B+ Tree (B+ Tree)?

B+ tree is a commonly used, efficient, self-balancing tree data structure
B+ tree is a balanced search tree
B+ tree is a variant of B tree, it is a balanced search tree

2.2 Purpose of B+ Tree (B+ Tree)

B+ Tree (B+ Tree) is suitable for external storage,
B+ Tree (B+ Tree) can be used to efficiently store and retrieve large amounts of data
B+ Tree (B+ Tree) is mainly used for disk storage and file systems,
B+ Tree (B+ Tree) is suitable for needs Quickly find and sort scenes.
B+ Tree (B+ Tree) can efficiently perform file indexing and database indexing.

2.3 Internal structure of B+ tree (B+ Tree)

The number of child nodes of each node is fixed, and the node where an element is located can be quickly located when querying.

  • In a B+ tree, internal nodes only store keywords and pointers to child nodes.
  • Internal nodes all hold keys and pointers to child nodes.

Only leaf nodes hold actual data.
Each leaf node holds data and a pointer to the next leaf node.
Leaf nodes only store keywords and pointers to the next leaf node.
Only leaf nodes hold pointers to the next leaf node.
Each node can only hold one key and multiple pointers.
Each node can have multiple child nodes
Each node can store multiple elements.
Each node contains a list of pointers to its child nodes, and a pointer to its associated element.
The number of child nodes of each node is also fixed, usually M (M is a larger integer, such as M=16).

2.4 Advantages of B+ Tree (B+ Tree)

When querying, you can quickly locate the node where an element is located, because each node of the B+ tree contains a subset of the elements contained in its child nodes, and the number of child nodes of each node is fixed .

Guess you like

Origin blog.csdn.net/wstever/article/details/129978063