Tag：Binary tree

Time：20201123
337. Robbery III Source: leetcode https://leetcodecn.com/problems/houserobberiii 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 […]

Time：20201121
100. The same tree Source: leetcode https://leetcodecn.com/problems/sametree 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 […]

Time：20201116
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 […]

Time：20201110
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 […]

Time：20201110
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。 […]

Time：2020119
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, […]

Time：2020115
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 […]

Time：20201030
110. Balanced binary tree Source: leetcode https://leetcodecn.com/problems/balancedbinarytree 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 […]

Time：20201029
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 socalled […]

Time：20201024
111. Minimum depth of binary tree Source: leetcode https://leetcodecn.com/problems/minimumdepthofbinarytree 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, […]

Time：20201010
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> […]

Time：2020109
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 […]