9-7-balanced binary sorting (Search) tree-search-Chapter 9th-Data Structure textbook source code-yan Weimin Wu Weimin edition, 9-7-Data Structure
Textbook source code
Chapter 2 search-balanced binary sorting (Search) Tree
-- Data Structure-yan Weimin. Wu Weimin
Source code instructions☛☛☛Data Structure-C language version (Yan Weimin, Wu Weimin version) Textbook source code + EXERCISE set parsing instructions
Textbook source code compilation Link☛☛☛Data Structure textbook source code compilation
Question set full resolution Link☛☛☛Analysis and compilation of data structure question set
File links introduced in this source code☛Base. c
Test data download link☛Data Packets
Source code and test data storage directory in the document: Data Structure \ ▲textbook Algorithm Implementation \ ▲09 lookup \ 07 BalancedBinarySortTree
Overview
A Balanced Binary Tree (AVL Tree) is called a Balanced Binary Tree (different from the AVL algorithm ).
Analysis
One balanced binary sorting(Search)Tree or an empty tree, or a binary sorting tree with the following properties:
(1) If the left subtree is not empty, the value of all nodes on the left subtree is smaller than the value of its root node;
(2) If the right subtree is not empty, the value of all nodes on the right subtree is greater than the value of its root node;
(3) The left and right Subtrees are also balanced binary decision trees;
(4) There are no nodes with equal key values.
(5) the absolute value of the height difference between the left subtree and the right subtree is less than or equal to 1 (different from that of the common Binary Tree ).
For a common Binary Search Tree, the expected height (that is, when it is a Balance Tree) is log2n, and the time complexity (O (log2n) of each operation is also determined by this. However, in some extreme cases (such as when the inserted sequence is ordered), the binary search tree degrades to an approximate chain or chain, the time complexity of its operations degrades to linear, that is, O (n ). We can avoid this problem by creating a binary search tree in randomization mode. However, after multiple operations, we always choose to replace the successor of the node to be deleted, which will reduce the number of nodes on the right, so that the tree is sunk to the left. This also damages the balance of the tree and increases the time complexity of its operations.
A Balanced Binary Tree has the following properties: it is an empty Tree or its left and right subtree. The absolute value of the height difference cannot exceed 1, both left and right Subtrees are balanced binary trees. Common algorithms include red/black trees, AVL, Treap, and stretch trees. In the balanced binary search tree, we can see that its height is generally well maintained at O (log (n), greatly reducing the operation time complexity.
Source code
File 1☛BalancedBinarySortTree. h
File 2☛BalancedBinarySortTree. c
File 3☛BalancedBinarySortTree-main.c (test documentation)
File 4☛TestData_Table.txt (query table test data)
Test Result Display
Updating more chapters...