Tag：Binary tree

Time：2021727
Point canvas animation code file every week In the previous sectionWeekly canvas animation – 3D physical effectsIn, we introduce the effects of velocity and acceleration in threedimensional environment. In this section, we continue to introduce two other physical effects:Gravity and screen surround。 1、 Gravity The way to realize the gravity effect in the threedimensional system […]

Time：2021727
The pre order, middle order and subsequent traversal of binary tree are the basic problems in algorithm and data structure. The binary tree traversal algorithm based on recursion is a classic application of recursion. Suppose the binary tree node is defined as follows: 1 // C++2 struct Node {3 int value;4 Node *left;5 Node *right;6 […]

Time：2021725
Diameter of binary tree Hi, everyone, I’m Zhang Xiaozhu. Welcome to the special article of the “baby can understand” series – the official activity “30 day leetcoding challenge”. Here is the question of April 11 and the 543rd question in the list – “diameter of binary tree” Title Description Given a binary tree, you need […]

Time：2021721
Statement: the content of this article is only for reference. If there is any mistake, the blogger strongly hopes you to point out. If you are the original blogger of a certain knowledge point, if necessary, you can contact me and add a link. The content of this article will be updated according to the […]

Time：2021718
Title: input the root node of a binary tree to determine whether the tree is a balanced binary tree. If the depth difference between the left and right subtrees of any node in a binary tree is less than 1, then it is a balanced binary tree. Thinking:Use an auxiliary function to calculate the depth […]

Time：2021717
Take a coin LCP 06. Take the coin class Solution: def minCount(self, coins) > int: cnt = 0 for x in coins: cnt += x >> 1 cnt += x & 1 return cnt Passing on information LCP 07. Delivering information class Solution: def numWays(self, n: int, relation: List[List[int]], k: int) > int: x = […]

Time：2021716
What is a binary tree In computer science, binary tree is a tree structure in which each node has at most two branches (that is, there is no node with branching degree greater than 2). Branches are usually called “left subtree” or “right subtree”. The branch of binary tree has the order of left and […]

Time：2021715
Symmetric binary tree Create a function to determine whether a binary tree is symmetric As shown in the figure, this is a symmetric binary tree Note that this is not a symmetric binary tree Idea: start from the root node, compare its left subtree and right subtree nodes, and then recurse successively. As long as […]

Time：2021714
What is a binary search tree Binary search tree is also called binary search tree, ordered binary tree or sorted binary tree He has the following properties: If the left subtree of any node is not empty, the values of all nodes in the left subtree are less than the values of its root node; […]

Time：202171
Title addresshttps://leetcodecn.com/problems/invertbinarytree/ 1. Recursion Time complexity O (n) space complexity O (n)The idea of recursion is to find the termination condition of recursion. The termination condition of recursion can only end recursion if the current node is null. Or we can think about it from another perspective. If this node is not null, it may […]

Time：2021628
Breadth traversal of binary tree Binary tree sequence traversal Binary tree depth traversal: preorder, mesorder, postorder Maximum depth of binary tree Binary search Given the path, traverse the tree to find the node with or without the specified path Quick sort The K largest Longest Common Prefix Longest substring without repeating characters There are many […]

Time：2021628
If a linear table is required to be able to find quickly and adapt to the requirements of dynamic changes, it can be used （ Block search method. Block search, also known as index search, divides a table into several blocks. The principle of block is that the keywords of data elements are ordered between […]