数据结构:树
文章平均质量分 65
model1220
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Java:求二叉树中节点的最大距离
class Node{ public int data; public Node left; public Node right; public int leftmaxdistance; public int rightmaxdistance; public Node(int data) { this.data=data; this.left=null; this.righ原创 2017-10-06 20:18:22 · 1281 阅读 · 0 评论 -
Java:树的最大深度
如何求二叉树的最大深度呢? 利用的方法是深度搜索,终止条件是左右孩子为空。 static int getmax(treenode node) { if(node==null) { return 0; }else { int lef=getmax(node.left); int rig=getmax(node.right); return Math.max原创 2017-09-13 20:29:34 · 1418 阅读 · 0 评论 -
Java:求树最小的深度
问题描述: 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. 这里要求根节点到最近的叶子节点的距离,原创 2017-09-13 19:55:35 · 812 阅读 · 0 评论 -
Java:二叉树的递归遍历
class TreeNode{ private Object data; public Object getData() { return data; } public void setData(Object data) { this.data = data; } TreeNode left=null; TreeNode right=null; } public class原创 2017-10-07 21:00:36 · 372 阅读 · 0 评论
分享