Construct Binary Tree from Inorder and Postorder Traversal
Total Accepted: 14363 Total
Submissions: 54254My Submissions
Given inorder and postorder traversal of a tree, construct the bina...
分类:
其他好文 时间:
2014-09-11 07:41:51
阅读次数:
149
给定一个字符串类型(string)表示的小数,打印出它的二进制表示。
这个题注意字符串的合法性。
不过下面的代码没有处理那种无限循环的小数,
当出现无限循环小数时,while(other>0)可能永久为true
代码:
#include
#include
std::string to_binary_string(const std::string& vNumStr)
{
std:...
分类:
其他好文 时间:
2014-09-11 01:11:31
阅读次数:
316
思路:与Binary Tree Level Order Traversal I几乎一样。只是最后将结果存放在栈里,然后在栈里再传给向量即可。再次总结思路:两个queue,先把第一个放进q1,循环q1是否为空,不为空就读取并出列,如果root有孩子就放入q2,最后清空q2。注意:for循环的时候不要使...
分类:
其他好文 时间:
2014-09-10 23:38:11
阅读次数:
274
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which rep...
分类:
其他好文 时间:
2014-09-10 22:23:11
阅读次数:
265
说说:
这道题略坑,好久没做过这么坑的题目了QAQ。这题初看挺复杂的,其实就是个树的遍历问题而已。首先题目给你类似如下的一个结构:
A
|
--------
B C D
| |
----- -
E F G
这其实是一棵树。‘|’,‘-’可以看成是树干。然后节点字符是除‘|’,‘-’,‘#’,‘ ’以外的其他可显示的字符。若一个节点有子节点,...
分类:
其他好文 时间:
2014-09-10 19:32:41
阅读次数:
230
转自:http://student.zjzk.cn/course_ware/data_structure/web/chazhao/chazhao9.2.2.1.htm二分查找1、二分查找(Binary Search) 二分查找又称折半查找,它是一种效率较高的查找方法...
分类:
其他好文 时间:
2014-09-10 19:25:40
阅读次数:
305
实际中估计也没有这个需求,只是写写。
能不能直接由2进制转为16进制呢,最直接的办法是通过位移操作,也就是通常所说的 每四位二进制对应一个16进制,
假如java中有一种 二进制的基础类型 Binary bi = new Binary(11010101);这样的话 进行 bi >>> 4 位移操作 就可以很容易转换了,关于这个可以参考Integer.java中的toHexString(in...
分类:
其他好文 时间:
2014-09-10 15:54:10
阅读次数:
287
Construct Binary Tree from Preorder and Inorder Traversal
Total Accepted: 14824 Total
Submissions: 55882My Submissions
Given preorder and inorder traversal of a tree, construct the binary...
分类:
其他好文 时间:
2014-09-10 14:16:11
阅读次数:
158
??
FreeEIM Linux rpm 命令参数使用详解[介绍和应用]
RPM是RedHat Package Manager(RedHat软件包管理工具)类似Windows里面的“添加/删除程序”
rpm 执行安装包
二进制包(Binary)以及源代码包(Source)两种。二进制包可以直接安装在计算机中,而源代码包将会由RPM自动编译、安装。源代码包经常以src.r...
分类:
系统相关 时间:
2014-09-10 10:53:40
阅读次数:
370
Path Sum II
Total Accepted: 18489 Total
Submissions: 68323My Submissions
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.
For exampl...
分类:
其他好文 时间:
2014-09-10 01:38:49
阅读次数:
223