Tag：Binary tree

[leetcode] a series of derivative problems of binary tree traversal
Non recursive traversal Non recursive preorder traversal Iterative traversal is assisted by stack, which stores the parent node to traverse the current subtree, and then traverse the sibling subtree of the current subtree. The idea is clear. Just pay attention to the judgment conditions of the cycle. class Solution { public: vector<int> preorderTraversal(TreeNode* root) { […]

[issue 32] spring recruit golang internship: seven cattle
One side (ask too many questions, just remember these) 1. The difference between red black tree and binary search tree 2. The difference between red black tree and balanced binary tree is compared with balanced binary tree. 3. Methods to resolve hash conflicts 4. Consistent hash algorithm 5. LRU algorithm What is the difference between […]

Python class – collections abc
Classes are very important for our daily programming. You will find that we define classes most of the time. Class contains data and uses methods to describe the interaction between data. Therefore, from a certain level, classes in Python are containers used to encapsulate attributes and functions. Python builtin container types:list tuple set dict, you […]

Binary tree
Normal tree building and traversal Preorder traversal void Pre(node *F){ if(!F)return; cout<value; Pre(F>L); Pre(F>R); } code /** *Input format: abc##de#g##f### **/ #include using namespace std; //Define chain tree struct btnode { char value; btnode *lc; btnode *rc; }; //Pre order tree building void build(btnode *&F) { char ch; cin>>ch; if(ch==’#’) F=NULL; else { F=new btnode; […]

In depth understanding of data structure — binary tree (advanced part 1)
Series articles： In depth understanding of data structure — binary tree (advanced part 1) In depth understanding of data structure — binary tree (basic chapter) In the first part, the relative basic information of binary tree is sorted outIn depth understanding of data structure – binary tree (basic chapter) Next, we will explain the advanced […]

[issue 38] background development of two cool classics
C + + and golang are written on the resume, so both languages are involved one side: How does golang design a producer consumer model Understanding of channel and goroutine String implementation subtraction Quick sort C + + virtual function Communication mode of process deadlock Two sides: Several operations of Linux Find a path in […]

Programming bear explains leetcode algorithm “binary tree”
Hello, I’m a programming bear. In the past, we learned the relevant knowledge of linear table together. In this issue, we will study binary tree together. Most of the problems of binary tree are based on recursion. According to the requirements of the problem, we will record the key information in the recursion process to […]

Data structure: understand binary search tree (JavaScript)
Introduction to binary search tree Binary search tree is a binary tree with a certain order of magnitude between node values. For each node in the tree: If the left subtree exists, the value of each node in the left subtree is not greater than the value of the node; If its right subtree exists, […]

[data structure balance tree] common fhq_ Treap from entry to mastery (more comments than code Series)
General fhq_ Treap from entry to mastery (more comments than code Series) The premise is that the author is too tired to write notes. Part of the explanation in the article comes fromOiwikiAnd according to the code, there are some additions and modifications. This article is only published onBlog GardenAnd knowThe hesitation of the wind, […]

Algorithm notes – Chapter 9 ~ Chapter 10 summary of various definitions
Binary tree: Or the binary tree has no root node and is an empty tree. The subtree is composed of left and right subtrees, and the subtrees are either left and right subtrees. Full binary tree: The number of nodes in each layer has reached the maximum number of nodes that can be reached in […]

Binary tree related processing, including recursive and non recursive methods
1. Introduction Be familiar with various characteristics of binary tree, including pre order, middle order, post order traversal, restoring binary tree and so on Mainly collected recursive and non recursive schemes, which can be compared and studied Learning this is also to brush questions on leetcode The following program running results {1 {2 {0 {3 […]

Draw a binary tree according to the hierarchical traversal sequence
1. Draw the following SVG vector diagram G 1 1 2 0 1>2 3 2 1>3 4 4 2>4 5 0 2>5 8 6 4>8 9 7 4>9 14 3 8>14 10 1 5>10 6 4 3>6 7 5 3>7 11 6 6>11 12 5 6>12 13 4 7>13 2. Release the source code package […]