From & quot; output by level of Binary Tree & quot; To & quot; solution of Binary Tree depth & quot;, binary tree depth

Source: Internet
Author: User

Summary from "output binary tree by hierarchy" to "solution Binary Tree depth", binary tree depth

This article is in the study of the summary, welcome to reprint but please note the Source: http://write.blog.csdn.net/postedit/41964669


Recently, the algorithm questions on LettCode have found that the ideas for solving many questions are basically the same, and there may even be a case of multiple questions, one reason may be that I click on simple questions, and the other reason may be that the website intends to improve our confidence and Lenovo ability. For example, if you have questions about the maximum depth of a binary tree and the minimum depth of a binary tree, you have questions about whether the two trees are completely consistent and whether the two trees are symmetrical, there are also questions about how to output each layer of elements from the root of the tree hierarchy to the root of the tree hierarchy.


Yesterday I answered the question of outputting each layer of elements from the root of the tree at a level. Today I happen to have three similar questions. I didn't mean to talk about these questions, instead, I think the ideas of algorithms are the same. Instead of being isolated, one algorithm can be transformed into another. You may only need to add some simple conditions, therefore, I think that even though we can improve our algorithm level, we cannot draw inferences from each other. If we have more associations when making a question, consider other possible methods. Over time, our thinking and problem analysis capabilities will also be improved. Let me take it for myself. I have never done any algorithm questions before, except for some knowledge I learned in the school data structure class. At the beginning, it was very difficult to make a simple question Algorithm on LettCode. I had to think about a question for half a day or even a day, because I had never had algorithm-related training before, and the thinking process was not so flexible, however, I insist that I think about each question and analyze each question myself. No matter how bad my algorithm is, as long as it is right, it is not necessary for a newbie like himself to start with such a high requirement. After accumulating more than 20 simple questions, I found that my thinking is no longer so rigid. I will contact other related questions through one question. I think each algorithm question will definitely correspond to a certain problem, corresponding to an application scenario, or no one will ask the problem, and there is no need to solve it. I will continue to stick to it, from simple questions to difficult questions, from easy to hard, and stick to finishing the 166 existing questions. This process may be a process of growth. It doesn't need a perfect result. You just need to stick to yourself, do what you want to do, and constantly improve yourself, starting from a simple start, starting from the basics, gradually surpass yourself and improve yourself.


Share some of the experiences in this short period of time:

(1) do not go far. Start from simple, or why do we divide the questions into simple, medium, and difficult ones? The high-rise building starts from the ground.

(2) stick to it. Every two days, I will take the time to do my exercises. Although I am very busy at work, I will seize the dark time around me and you will soon find yourself different.

(3) independent thinking. Do not think about Baidu for a moment. What you think will never be forgotten. Try to think for yourself and improve your thinking ability.

(4) share. Write down your ideas and share them with you. The reward for sharing knowledge is not simply the sum of knowledge, but linear or even exponential.


Hope to help you. Thank you.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.