摘要:
import java.util.*;class treenode{ public char val; int left; int right;}public class Main { public static int root = -1; //全局变量 public static treenod 阅读全文
摘要:
思路:两个栈s1和s2,遍历s1时按左到右顺序在s2存放子树根节点,遍历s2时按从右到左顺序在s1存放子树根节点 public class Solution { public ArrayList<ArrayList<Integer> > Print(TreeNode pRoot) { ArrayLi 阅读全文
摘要:
将BST转成双向链表,相当于中序遍历 非递归法: public class Solution { public static TreeNode Convert(TreeNode pRootOfTree) { TreeNode p = pRootOfTree; TreeNode q = null; i 阅读全文
摘要:
利用arraylist构造treenode的队列,将每个结点的值输出并将每个结点的左右子树依次入队。 import java.util.ArrayList; public class Solution { public ArrayList<Integer> PrintFromTopToBottom( 阅读全文