写了个Java的查找二叉树,用递归做的,不用递归的还没弄出来.先贴一下.回头再研究. BTreeTest.java: public class BTreeTest{ class Node{ Node left, right; int data; Node(int newData){ left = null; right = null; data = newData; } } Node root = null; int count = 0; boolean canFind = false; pub…
题目: minimum-depth-of-binary-tree 要求:Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 思路: 两种方法: 第一,使用递归,相当于遍历了整个二叉树,递归返回深度浅的那棵子树的深度. 第二,按层检查…