![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
Cherish丶
这个作者很懒,什么都没留下…
展开
-
二叉树的层次遍历
二叉树的层次遍历要实现二叉树的层次遍历,需要借助队列实现,这种方法也称为宽度优先遍历(Breadth-First Search, BFS)。主要思想是,借助队列,先将根结点入队,开启循环,队列为空的时候循环结束,每一个结点出队时,就把该结点的左右子节点(如果存在)放进队列。public class Trees { public static void main(String[] a...原创 2019-04-11 20:38:04 · 128 阅读 · 0 评论 -
树(Tree, Uva 548)
Tree, Uva 548You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary tree to any leaf. The value of a pat...原创 2019-04-12 17:40:59 · 195 阅读 · 0 评论 -
小球下落 Dropping Balls, UVa 679
小球下落 Dropping Balls, UVa 679题目描述有一棵二叉树,最大深度为D,且所有的叶子深度都相同。所有结点从上到下从左到右编号为1,2,3,…,2eD-1。在结点1处放一个小球,它会往下落。每个结点上都有一个开关,初始全部关闭,当每次有小球落到一个开关上时,它的状态都会改变。当小球到达一个内结点时,如果该结点的开关关闭,则往上走,否则往下走,直到走到叶子结点,如下图所示。...转载 2019-04-09 20:47:04 · 193 阅读 · 0 评论