Skip to main content
Binary Tree Questions 二叉树问题

Binary Tree Questions 二叉树问题

This article is concluded from this article in Chinese.

Cheatsheet: Steps to solve binary tree questions

  1. Can we get the answer by traversing the binary tree once? 是否能通过遍历一棵树来获取结果?
  2. If not, can we define a recursive function that gets the answer to the original question from the answer to the subtree? If the solution involved the information of the subtree, it is recommended to use post-order position to handle data. 如果不能,是否能通过递归的方式获取子树的结果,再根据子树的结果计算最终结果。通常而言,由于需要子树的结果,常在后序位置处理节点数据。
  3. No matter which model you are using, we need to think about what and when should we do for a single node? (Pre/In/Post-order) 无论使用哪一种思维模式,都要明白二叉树的每一个节点需要做什么,需要在什么时候(前中后序)做

Yujie LiuAbout 6 minComputer ScienceAlgorithmsLeetcodeBinary Tree