Tag:Binary tree

  • Leetcode 337. Robbery III | Python

    Time:2020-11-23

    337. Robbery III Source: leetcode https://leetcode-cn.com/problems/house-robber-iii subject After the last robbery of a street and a circle of houses, the thief found a new feasible area to steal. There is only one entrance to this area, which we call “root”. In addition to the “root”, each house has and only one “father” house connected to […]

  • Leetcode 100. The same tree | Python

    Time:2020-11-21

    100. The same tree Source: leetcode https://leetcode-cn.com/problems/same-tree subject Given two binary trees, write a function to check whether they are the same. Two trees are considered identical if they are structurally identical and nodes have the same value. Example 1: Input: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] Output: true […]

  • Understand the origin of red black tree and understand the essence of red black tree

    Time:2020-11-16

    preface This article is on the album:http://dwz.win/HjK, click to unlock more knowledge of data structures and algorithms. Hello, this is tongge. In the first two sections, we learned about the theory of skip table and handwritten two completely different implementations. Let’s put a picture to briefly review: The key to implement the skip table is […]

  • 18 graphs, one article to understand 8 common data structures

    Time:2020-11-10

    A few days ago, I communicated with AO Bing. He said that the people who write are burning themselves constantly, so they need to keep replenishing fuel. I couldn’t agree with him any more – so I began to cram into the basics of computers, including my relatively weak data structure. Baidu Encyclopedia defines data […]

  • Binary search tree of leetcode problem solving series

    Time:2020-11-10

    Binary search tree Advertisement: Recently, GitHub has opened a new warehouse may nodes, including but not limited to the related database, computer operating system, java basic knowledge, computer network and leetcode algorithm problem solving knowledge. Pdf documents and resources for learning will also be sorted out. Small partners in need can pay attention to andstar。 […]

  • Structure and algorithm (05): binary tree and multi tree

    Time:2020-11-9

    Source code:GitHub. Click here || Gitee. Click here 1、 Tree structure 1. Array and linked list Array structure Array storage is to access the elements by subscript, and the query speed is fast. If the array elements are ordered, binary search can also be used to improve the retrieval speed; if new elements are added, […]

  • Print binary tree from top to bottom

    Time:2020-11-5

    Python is short and sharp, and golang is simple and efficient Question surface Each node of the binary tree is printed from top to bottom, and the nodes of the same layer are printed from left to right.Given binary tree[3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return [3,9,20,15,7] python Queue in and […]

  • Leetcode 110. Balanced binary tree | Python

    Time:2020-10-30

    110. Balanced binary tree Source: leetcode https://leetcode-cn.com/problems/balanced-binary-tree subject Given a binary tree, judge whether it is a highly balanced binary tree. In this paper, a height balanced binary tree is defined as: The absolute value of the height difference between the left and right subtrees of each node of a binary tree does not exceed […]

  • Micro course lesson 6 complex query

    Time:2020-10-29

    https://v.youku.com/v_show/id_XNDQ2MDAzOTE2MA==.html In the last issue, we used the basic split algorithm to show what the basic configuration looks like. Now let’s introduce some other functions of dble. Dble query flow chart First of all, we have introduced the basic DML, and here we will introduce the complex query. As shown in the figure, the so-called […]

  • Leetcode 111. Minimum depth of binary tree | Python

    Time:2020-10-24

    111. Minimum depth of binary tree Source: leetcode https://leetcode-cn.com/problems/minimum-depth-of-binary-tree subject Given a binary tree, find its minimum depth. The minimum depth is the number of nodes on the shortest path from the root node to the nearest leaf node. Note: leaf node refers to the node without child nodes. Example: Given the binary tree [3,9,20, […]

  • The most elegant non recursive traversal template of binary tree

    Time:2020-10-10

    Leetcode 144. Preorder traversal of binary trees The right child is the first to press the stack, and then the left child. Due to the characteristics of the stack, the left child is taken out first, and then the right child is taken outRoot left right。 class Solution { public: vector<int> preorderTraversal(TreeNode* root) { vector<int> […]

  • What is a heap in the series of data structure? It’s enough to read this one

    Time:2020-10-9

    This paper will first introduce what is a heap, then introduce the heap insert and delete operations, and finally give the code implementation of heap and test. What is a heap Heap is a complete binary tree, the value of a node in the heap is always no greater than or not less than the […]