Tag:Binary tree

  • “Canvas animation every Monday” — forest and star sea


    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 three-dimensional 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 three-dimensional system […]

  • Binary tree iterative algorithm


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

  • [activities that babies can understand] [30 day leetcoding challenge] day 11


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

  • C + + server interview preparation (3) data structure and algorithm


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

  • Leetcode balanced binary tree


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

  • 2020 force buckle cup! Code your future spring national programming contest – Python code


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

  • Binary tree (1): traversal


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

  • Binary tree (2): Supplement


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

  • Binary tree (3): binary search tree


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

  • Leetcode-0226 flipped binary tree


    Title addresshttps://leetcode-cn.com/problems/invert-binary-tree/ 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 […]

  • Algorithm of handwritten topic


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

  • Search (exercise class)


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