https://leetcode.com/problems/all-possible-full-binary-trees/ 给定节点个数,求所有可能二叉树,该二叉树所有节点要么有0个子节点要么有两个子节点.返回所有二叉树的头指针. 一开始一直想的是从根节点开始建树,一直想不出来方法.后来想到可以从子节点开始建树,问题就很好解决了. class Solution { public: vector<TreeNode*> allPossibleFBT(int N) { vector<TreeN…
Counting Binary Trees Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 493 Accepted Submission(s): 151 Problem Description There are 5 distinct binary trees of 3 nodes: Let T(n) be the number of di…
1. Definiation What is Binary Trees? Collection of node (n>=0) and in which no node can have more than two children. 或为空集,或为有一个根节点和两棵互不相交的二叉树组成 左子树与右子树是有顺序的,不能颠倒 即使是只有一颗子树也要分清是左子树还是右子树 2. property (1)  若二叉树的层次从1开始,则在二叉树的第i 层最多有2^(i-1)个结点: (2)高度为k 的二叉…
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then…
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then…
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then…
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then…
Given an array of unique integers, each integer is strictly greater than 1. We make a binary tree using these integers and each number may be used for any number of times. Each non-leaf node's value should be equal to the product of the values of it'…
A full binary tree is a binary tree where each node has exactly 0 or 2 children. Return a list of all possible full binary trees with N nodes.  Each element of the answer is the root node of one possible tree. Each node of each tree in the answer mus…
For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip opera…