144. Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,2,3]. Note: Recursive solution is trivial, could you do it iteratively? # De…
问题: Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree{1,#,2,3}, 1 \ 2 / 3 return[3,2,1]. 递归方法: /** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode ri…
#include <stdio.h> #include <stdlib.h> typedef struct tree { int number ; struct tree *left ; struct tree *right ; }TREE; //对树插入节点 void insert_tree(TREE **header , int number) { //创建一颗树 TREE *New = NULL ; New = malloc(sizeof(TREE)); if(NULL ==…