AVL tree - balanced binary tree
catalog:
I Concept & principle
Previously, we understood the binary search tree, but we found that if the data is orderly or close to orderly, the binary search tree will degenerate into a single tree
AVL tree is a balanced binary tree. It just adds a balance factor to the binary search tree to form the current balanced bi ...
Added by cbrknight on Fri, 11 Feb 2022 13:19:17 +0200
Sword finger offer related exercises (3 ~ 10)
catalogue
Title: Sword finger offer03: repeated numbers in the array
Title: Sword finger offer04: search in two-dimensional array
Title: Sword finger offer05: replace spaces
Title: Sword finger offer06: print linked list node information from end to end
Title: Sword finger offer07: reconstruction of binary tree (pre order + middle order)
...
Added by Fusioned on Thu, 10 Feb 2022 12:33:27 +0200
AVL tree introduction and detailed explanation of each operation
AVL tree introduction and detailed explanation of each operation
Introduction to AVL treeImplementation of AVL tree operation set
rotate
RR insertion (left single rotation)LL insertion (right single rotation)RL insertion (right left double rotation)LR insertion (left and right double rotation) insertdeleteergodic Complete code
Code ...
Added by slimsam1 on Wed, 09 Feb 2022 09:01:51 +0200
Super detailed analysis of [data structure] tree and binary tree
This article is long. You can click the directory below to view the corresponding content.
I tree
1. Basic concepts
tree is a nonlinear data structure, which consists of n nodes and a set with hierarchical relationship. In fact, it is a big tree growing upside down, with many leaves added to one root. the tree must con ...
Added by jhonrputra on Tue, 08 Feb 2022 15:24:34 +0200
LeetCode 106. Constructing binary tree from middle order and post order traversal sequence [c++/java detailed problem solution]
1. Title
Given two integer arrays inorder and postorder, inorder is the middle order traversal of the binary tree and postorder traversal of the same tree, please construct and return this binary tree.
Example 1:
Input: inorder = [9,3,15,20,7], postorder = [9,15,7,20,3]
Output:[3,9,20,null,null,15,7]
Example 2:
Input: inorder = [-1 ...
Added by mchaggis on Sun, 06 Feb 2022 04:55:56 +0200
Binary search tree
Binary search tree concept
Binary search tree, also known as binary sort tree, is either an empty tree or a binary tree with the following properties:
If its left subtree is not empty, the value of all nodes on the left subtree is less than that of the root nodeIf its right subtree is not empty, the value of all nodes on the right subtree is ...
Added by geoffjb on Thu, 03 Feb 2022 11:10:36 +0200
[C + +] [binary tree] [binary search tree] build a binary search tree class.
1, Key analysis
1. Insert node
Inserting a node is relatively simple. You only need to judge the key value, replace the corresponding key value, or create a new key value.
// Insert the node (key, value) into the binary search tree with node as the root, and use the recursive algorithm
// Returns the root of the binary search tree ...
Added by dietkinnie on Tue, 01 Feb 2022 21:46:07 +0200
Traversal of binary tree
preface:
·The depth first traversal and width first traversal of binary tree are the basis for solving the problem of binary tree. Mastering the common traversal methods of binary tree can make us solve the problem of binary tree more handy.
catalogue
preface:
Recursive form of pre -, middle - and post order traversal of binar ...
Added by webpals on Tue, 01 Feb 2022 11:52:55 +0200
Detailed explanation of binary tree and typical questions of force buckle
1, Types of binary trees
1. Full binary tree
Except that the last layer has no child nodes, all nodes on each layer have two child node binary trees (if the depth is k, there are 2^k-1 nodes).
2. Complete binary tree
Let the depth of a binary tree be H. Except for layer h, the number of nodes in other layers reaches the maximum, and all n ...
Added by xxxzom_biexxx on Mon, 31 Jan 2022 08:43:07 +0200
Final review and search of data structure
I Sequential search
The principle is to find = = one by one. The code is as follows
int order_search(char *p){
int i = 0;
while(i<3367 && strcmp(p,word[i])>0){
i++;
cnt++;
}
cnt++;
//printf("%d\n",cnt);
if(strcmp(p,word[i])==0) return 1;
else return 0;
}
Efficiency analysis:
Average search length ASL: (1+...+n)/n = ...
Added by danjar on Sun, 30 Jan 2022 22:56:37 +0200