
算法
文章平均质量分 76
_Zqqq
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Morris Traversal方法遍历二叉树(非递归,不用栈,O(1)空间)
本文主要解决一个问题,如何实现二叉树的前中后序遍历,有两个要求: 1. O(1)空间复杂度,即只能使用常数空间; 2. 二叉树的形状不能被破坏(中间过程允许改变其形状)。 通常,实现二叉树的前序(preorder)、中序(inorder)、后序(postorder)遍历有两个常用的方法:一是递归(recursive),二是使用栈实现的迭代版本(stack+iterative)。这两种方法都是转载 2017-03-24 17:10:23 · 204 阅读 · 0 评论 -
rabbit
#include #include #include using namespace std; struct Rabbit { int age; int maxAge; }; void Age(vector &res) { for (vector::iterator it = res.begi原创 2017-08-20 17:36:03 · 389 阅读 · 0 评论