摘要:
1 //1 二叉搜索树的判定 2 //method 1 利用中序遍历(最优解) 对于任一结点 若它后一个结点的值大于它的值 则为二叉搜索树 3 //时间复杂度: O(n) 空间复杂度: O(1) 4 public boolean isBST(BiTNode node) 5 { 6 if(node == null) 7 return true; 8 9 ... 阅读全文
posted @ 2019-05-04 20:09
Huayra
阅读(218)
评论(0)
推荐(0)
摘要:
1 //1 二叉树的深度(在后序遍历的基础上进行 时间复杂度: O(n)) (即左右子树的最大深度加1) 2 public int getDepth(BiTNode node) 3 { 4 if(node == null) 5 return 0; 6 7 int count1, count2; 8 count1 = getDepth(node.lc... 阅读全文
posted @ 2019-05-04 11:58
Huayra
阅读(321)
评论(0)
推荐(0)
摘要:
1 public BiTNode createBiTree(BiTNode parent_node) 2 { 3 Scanner input = new Scanner(System.in); 4 int k = input.nextInt(); 5 if(k == -1) 6 return null; 7 8 BiTNode node ... 阅读全文
posted @ 2019-05-04 11:52
Huayra
阅读(517)
评论(0)
推荐(0)

浙公网安备 33010602011771号