• [NOIP2001 Popularization Group] Seek Ranking


    Question analysis: The question mentions the pre-order, in-order, and post-order arrangement of trees, so we need to know what these three arrangements mean first. 3 (depth-first) permutations of binary trees: Pre-order, "root left and right". That is, for each subtree of the binary tree, first visit its root, and then traverse its left and right […]

  • Getting Started with Splay (Balanced Tree)


    Be sure to put it first: super detailed Ditto +1 \(Splay\)a support function and\(Treap\)Pretty much the same thing, just more advanced (withsixrotation operation) Since it is a balanced tree, it has\(BST\)nature template \(Update\) void update(int p){ tr[p].size=tr[tr[p].son[0]].size+tr[tr[p].son[1]].size+tr[p].cnt; //Update the subtree size for query ranking ↑ } \(Rotate\) Basic rotation operation \(Treap\)The combined operation of left […]

  • 814. Binary Tree Pruning: Simple Recursive Application Problems


    Topic description This is on LeetCode814. Binary Tree Pruning, the difficulty ismedium。 Tag : "binary tree", "DFS", "recursion" gives you the root node of the binary treeroot, and the value of each node of the tree is either $0$ or $1$. Returns the original binary tree with all subtrees not containing $1$ removed. nodenodeThe subtree […]

  • Tree — balance binary tree and get all paths


    balanced binary tree     Title No     concept The absolute value of the height difference between the left subtree and the right subtree is less than or equal to 1     thinking Tree height means tree depth Since a tree is composed of N subtrees, it is necessary to recursively judge whether each tree is […]

  • [selected sword fingers] from a macro point of view, “symmetric binary tree”


    Title Description This is from niuke.com“JZ 58 symmetric binary tree”, difficulty is“Difficulties”。 Tag: “sword finger offer”, “binary tree”, “sequence traversal”, “iteration”, “recursion” Description: Please implement a function to judge whether a binary tree is symmetric. Note that if a binary tree is the same as the image of the binary tree, it is defined as […]

  • Data structure – (4) simple binary tree insertion and output


    1、 Concept Binary tree is an important type of tree structure. The data structure abstracted from many practical problems is often in the form of binary tree. Even a general tree can be simply transformed into a binary tree, and the storage structure and algorithm of the binary tree are relatively simple, so the binary […]

  • Binary tree question frame 4


    Binary search tree nature:1. For each node of the BST, the value of the left subtree is smaller than that of the node, and the value of the right subtree is larger than that of the node2. For each node of BST, its left subtree and right subtree are BST.From the perspective of algorithm problem, […]

  • Practical application of data structure and algorithm in process canvas


    Niklaus Wirth, the winner of the Turing prize and the father of Pascal, has a classic saying: “algorithm + Data Structures = programs”. We take this statement as the idea to see how to apply data structures and algorithms to solve the actual business needs in the scenario of process canvas. Tree and graph In […]

  • Life cycle of flutter


    3-2.a59bef97.jpg.png initState(): when the widget is inserted into the widget tree for the first time, it will be called. For each state object, the fluent framework will only call the callback once. Therefore, some one-time operations are usually done in the callback, such as state initialization, subscribing to event notification of subtree, etc. Buildcontext. cannot […]

  • 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 […]

  • Flitter state management 2-inheritedwidget example


    use Sharedatawidget inherits inheritedwidwidget and creates shared data Provides a convenient way for widgets in the subtree to obtain shared data class ShareDataWidget extends InheritedWidget { ShareDataWidget({@required this.data, Widget child}) : super(child: child); final int data; // Save the number of clicks of the data to be shared in the subtree //Define a convenient method […]

  • Provincial selection simulation 18


    A. Currency Consider maintaining the smallest left endpoint for each right endpoint, and record it as\(f_r\) that\(f_r=\min(i|nxt_i>r)\), where\(nxt_i\)Representation and\(i\)Next position with the same color Color merging can be combined by heuristic, and the color of each can be modified during insertion\(nxt\) consider\(u\)A series of points of influence,\(f_i=u\)It is not difficult to find such interval continuity […]