Data structure

Red black tree, B tree

B tree

B-tree is a balanced multi-path search tree , which is mostly used in the realization of file systems and databases .
feature:

  • A node can store more than two elements
  • Balanced, the height of the node subtree is consistent
  • Has some properties of a balanced binary tree, which is relatively short
  • Logically equivalent to the binary search tree, the binary search tree can be converted to a B tree by merging parent and child nodes

Why use B tree for database index

The AVL number and the red-black tree are basically data structures that are only used when stored in memory , and the storage principle of the index is involved in the disk:

  • The page is the smallest disk unit for the InnoDB storage engine to manage the database. A page contains many data rows, and a parent node has only 2 child nodes. The B+ tree allows a parent node to have multiple child nodes.
  • Since the B+ tree has more branches than the binary tree, the depth of the B+ tree is shallower for the same amount of content. What does the depth represent? Represents the number of disk io! The search speed is faster, so when it comes to the data structure of the query on the disk, the B+ tree is generally used

The difference between array and linked list

The difference between an array and a linked list, what is the storage of the tree, can it be stored in an array?
The time complexity of fast sorting (NlogN), worst-case (N^2)
, what is the difference between the heap and the stack on the data structure, and the underlying structure? What sorting algorithm is used for the largest K number of
red-black trees
? The complexity is also NlogN. What is the difference between fast sorting and heap sorting.

Guess you like

Origin blog.csdn.net/qq_38879305/article/details/107204344