摘要: Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2014-07-29 23:40 purejade 阅读(67) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2014-07-29 23:30 purejade 阅读(81) 评论(0) 推荐(0) 编辑
摘要: 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 le... 阅读全文
posted @ 2014-07-29 23:20 purejade 阅读(90) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2014-07-29 22:51 purejade 阅读(73) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2014-07-29 22:25 purejade 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 1、打印汉诺塔移动步骤,并且计算复杂度。方法是递归,将n-1层移到中间柱,然后将最底层移到目标柱,然后再把n-1层移到目标柱。f(n) = 2f(n-1) + 1 , f(1) = 1f(n) + 1 = 2( f(n-1) + 1 )f(n) = 2^n - 1T(n) = O(2^n);2、计算... 阅读全文
posted @ 2014-07-29 18:45 purejade 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 转:http://blog.csdn.net/hackbuteer1/article/details/7581306一面:第一题、任意给一个数,试证明这个数的某个倍数的十进制表示是01串,比如3的倍数111是二进制表示,5的倍数10是二进制表示,等等。假设序列1,11,111,1111…用A1~AN... 阅读全文
posted @ 2014-07-29 18:14 purejade 阅读(117) 评论(0) 推荐(0) 编辑
摘要: C++中的智能指针是用一个类对另一个对象的指针或者引用进行管理,具体对该类的管理可以用包含对象指针以及引用计数的类来记录;一般有两种方式实现:1. 在对象内部记录引用的个数,这需要对象预留引用计数相关的接口2. 用一个单独的资源管理类进行管理,则不需要修改对象下面主要是第二种方法:(参考)http:... 阅读全文
posted @ 2014-07-29 18:07 purejade 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 1、 const 成员函数需要吗? 尽量不要,如果存在继承,则无法预支子类是否有可能改变data member2、 pure virtual constructor 可以实现类的隐藏吗(包含data member)? 这样子类无法调用base 的构造函数对数据初始化,所以可以用protected来... 阅读全文
posted @ 2014-07-29 11:06 purejade 阅读(207) 评论(0) 推荐(0) 编辑