Tag：Right son

Time：2021413
101. Symmetric binary tree subject Given a binary tree, check whether it is mirror symmetric. For example, a binary tree [1,2,2,3,4,4,3] is symmetric. 1 / \ 2 2 / \ / \ 3 4 4 3 But the following [1,2,2, null, 3, null, 3] is not mirror symmetric: 1 / \ 2 2 \ \ […]

Time：202132
Title Requirements Write a program to establish the binary list storage structure of the binary tree by using the preorder recursive traversal calendar (or input preorder and middle order recursive traversal node access sequence), calculate and output the total number of nodes and tree height of the binary tree, and then output its preorder, middle […]

Time：2021226
WeChat official account: Xiao Chao said This isSearch algorithmThe first article in the series helps you get started with binary trees What is a tree? Let’s start with some pictures: Among them, the first, second and fourth are all trees, and the third is not. The characteristics of trees are very obvious! Each element is […]

Time：2021222
1. Heap sort Heap sort is a sort algorithm designed with heap data structure. It is similar to a binary tree and has a characteristic that the value of parent node is greater than (less than) the value of child node. There are two kinds of heaps. The one whose parent node is larger than […]

Time：2021213
This isSearch algorithmThe second article in the series helps you master binary search tree thoroughly In the data structure, binary search tree is undoubtedly very important, but beginners have some difficulty in understanding, and the articles on the Internet are not very comprehensive.In this paper, we hope to combine multiple groups of moving pictures, pictures […]

Time：2021211
Binary tree Before that, let’s review the creation and basic methods of binary search treeMaster the following code, will be able to skillfully binary tree further operation var Node=function(key){ this.key=key; this.left=null; this.right=null; } class BinaryTree{ constructor(){ this.root=null; } //Insert node (as required by binary search tree) insert(key){ let newNode=new Node(key); if(this.root==null){ this.root=newNode; }else{ this.insertNode(this.root,newNode); } […]

Time：2021117
Basic experiment 42.1 isomorphism of trees given two trees T1 and T2. If T1 can be changed into T2 by several times of left and right child exchange, then we call two trees “isomorphic”. For example, the two trees shown in Figure 1 are isomorphic, because after we exchange the left and right children […]

Time：2021117
Title Requirements: Thinking: recursion Pass (sum – Val of the current node) to the left and right subtrees of the current node If the current node has no left subtree or right subtree, and sum is 0, it means that it has reached a leaf node, and there is a path in the path to […]

Time：202116
According to the preorder, the middle order constructs the binary tree 1. Title Description Input the result of preorder traversal and meso traversal of a binary tree, please rebuild the binary tree. Assume that the results of preorder traversal and meso traversal do not contain duplicate numbers. 2. Examples For example, give Preorder traversal preorder […]

Time：202114
mapping Mapping with linked list Create map interface and implementation class. public interface Map<K, V> { void add(K key, V value); V remove(K key); boolean contains(K key); V get(K key); void set(K key, V value); int getSize(); boolean isEmpty(); } public class LinkedListMap<K, V> implements Map<K, V> { private class Node { public K key; […]

Time：20201229
AVL balanced binary tree Balanced binary search treeBalanced binary tree for short. Mathematicians from the former Soviet UnionAdelseVElskil andLThe highly balanced binary tree proposed by andis in 1962 is also called AVL tree according to scientists’ English name. It has the following properties It could be an empty tree. If it is not an empty […]

Time：20201212
package main import ( “fmt” “reflect” ) type BinaryNode struct { Data interface {} // data Lchild * binarynode // left subtree Rchild * binarynode // right subtree } //Creating a binary tree func (node *BinaryNode) Create() { node = new(BinaryNode) } //Preorder traversal func (node *BinaryNode) PreOrder() { if node == nil { […]