由买买提看人间百态

topics

全部话题 - 话题: binary
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
s*******2
发帖数: 1182
1
不至于这么惨吧,看看下面这位仁兄的见解:
发信人: wmwmw (wmw), 信区: Stock
标 题: Re: 搞了个关于投资binary option (二元期权)的网站
发信站: BBS 未名空间站 (Mon Jul 16 11:00:08 2012, 美东)
我做binary option很长时间了。以下提供我对这种衍生品的了解。
1.brokers方面,如果你是居住在美国,用nadex就行了。别的brokers相对要差的太多。
首先,Nadex虽然有spread和commission,但是比起其他brokers,你投资$100,做对了
,brokers只能给$70-$80。而Nadex的spread和commission一共也就增加5%的cost.
其次,只有nadex是个exchange,也就是你的对手是其他traders。所有nadex以外的
brokers,你的对手都是brokers本身。你赚钱,brokers就亏钱。这个就有利益冲突。
我以前在欧洲开过户。也是和house赌。网上不少欧洲traders反映,如果连续赚了不少
钱,就开始经常不能及时成交,或成交价比市... 阅读全帖
w***w
发帖数: 6301
2
我做binary option很长时间了。以下提供我对这种衍生品的了解。
1.brokers方面,如果你是居住在美国,用nadex就行了。别的brokers相对要差的太多。
首先,Nadex虽然有spread和commission,但是比起其他brokers,你投资$100,做对了
,brokers只能给$70-$80。而Nadex的spread和commission一共也就增加5%的cost.
其次,只有nadex是个exchange,也就是你的对手是其他traders。所有nadex以外的
brokers,你的对手都是brokers本身。你赚钱,brokers就亏钱。这个就有利益冲突。
我以前在欧洲开过户。也是和house赌。网上不少欧洲traders反映,如果连续赚了不少
钱,就开始经常不能及时成交,或成交价比市场价差很多。所以和house赌,是有潜在
风险的。
nadex的产品结构可以提供很多种牟利模式,你可以选择赌高概率低收益,也可以赌高
收益低概率。在有些环境下,有可能在半小时赚30倍。其他brokers就没有这么多选择。
2.做binary option确实需要对市场感觉... 阅读全帖
c**y
发帖数: 172
3
I come up with some questions when considering the following problem. A
related discussion is found here
http://stackoverflow.com/questions/1017821/find-whether-a-tree- but I didn't find the answer to my particular questions.
Problem: given two binary trees T1 (large) and T2 (small), how do we check
whether or not T2 is a subtree of T1? Brutal force solution is out of scope
of this post. Another solution is as follows. A general idea is to serialize
T1 and T2 into two arrays A(T1) and A(T2) firs... 阅读全帖
s******n
发帖数: 20
4
在leetcode看到Binary Tree Level Order Traversal II,看不出和Binary Tree
Level Order Traversal有什么根本区别,不知道考点在哪里?
我把Binary Tree Level Order Traversal的最终结果一颠倒不就得到Binary Tree
Level Order Traversal II.
Binary Tree Level Order Traversal的链接在这里:
http://discuss.leetcode.com/questions/49/binary-tree-level-orde
哪位大牛指点一下?先谢谢了。
c*********t
发帖数: 2921
5
来自主题: JobHunting版 - full or complete binary tree的问题
好像过去大概一个月左右的时候这里讨论过这个问题,找不到那个帖子了。
cracking the code interview (careercup)的书上说full, complete binary tree是
一回事,可是在别的地方看到的是full binary tree肯定是complete,但是complete
binary tree不一定是full.
我看到的是full binary tree,每个non-leaf node 肯定有两个children.但是complete
binary tree不是这样的。
谁能把那个帖子给弄出来?
谢谢!
x*****0
发帖数: 452
6
The question is:
Check if a binary tree is a valid binary search tree.
I guess I can pass the definition of the binary search tree in this forum. :
-). I know this is a very basic question and have a lot of solutions with O(
N) time complexity and O(1) space complexity.
Since I'm practicing how to use bottom-up traversal skill, Let's restrict
the answer must be bottom-up traversal algorithm.
The following is my idea.
Using "min" and "max" to represent the minimum value of left sub-tree and
maxim... 阅读全帖
M**********n
发帖数: 432
7
【 以下文字转载自 Computation 讨论区 】
发信人: ManshengChen (像琼瑶一样老去), 信区: Computation
标 题: How to read binary(data) file generated by Fortran in C/C++?
发信站: BBS 未名空间站 (Sat Oct 13 19:28:21 2007)
How to read binary(data) file generated by Fortran in C/C++?
Is it possible? If possible how to realize it?
The binary file generated by Fortran is a double precision data file.
I have tried to use read binary file in C++, but have problem. The following
is my C++
code.
double temp=0.0;
ifstream File("bin.data",i
M**********n
发帖数: 432
8
How to read binary(data) file generated by Fortran in C/C++?
Is it possible? If possible how to realize it?
The binary file generated by Fortran is a double precision data file.
I have tried to use read binary file in C++, but have problem. The following
is my C++
code.
double temp=0.0;
ifstream File("bin.data",ios::in|ios::binary);
File.read((char *) &temp, sizeof(double));
cout< The number that has been read out does not make any sense.
Anybody know why? Thanks.
C**********n
发帖数: 100
9
问个很基本的问题。
假定某个binary search tree和max heap都是有输入一些数字序列所构成,
那么是不是binary search tree跟输入数字的顺序无关,只可能有一种binary search
tree,
但max heap(或min heap)则跟输入数字的顺序有关,同样的几个数字,输入顺序不同所
形成的max heap也不一样?
c*********t
发帖数: 2921
10
来自主题: JobHunting版 - 问几个有关Binary tree的题
1. 如何用iterative 的方法实现postorder遍历binary tree?
recursive的方法太简单了。
好像inorder, preorder的iterative比较容易用stack就行了。可是postorder,我想不
出好的方法。谁能给个pseudo code?
2. 给定postorder 和 inorder遍历的结果,想个算法还原出binary tree.
3. 给定preorder 和 inorder遍历的结果,想个算法还原出binary tree.
我有三个包子,谁给回答对,就发包子给谁,一个包子一题。
给出pseudo code就行了。
谢谢!
t*****j
发帖数: 1105
11
来自主题: JobHunting版 - How many full binary trees?
我感觉这题应该用数学归纳法。
首先可以确定的是n一定要是奇数,偶数个数的n不存在full binary trees.
B(1) = 1
B(3) = 1
given B(n)
B(n+2): 实际上就是在B(n)个数上加两个节点。可以确定的是这两个节点一定是在一起
的。因为B(n)的所有节点都是偶数个小孩。要保持平衡只能加在同一个节点上。
所以这就是计算B(n)颗树总共有多少叶节点。总共有(n+1)/2个节点。因为每次的递
增都是只增加一个叶节点。
所以 B(n+2)=B(n)×(n+1)/2
然后算通式。。。

A binary tree is full if all of its vertices have either zero or two
children.
Let B_n denote the number of full binary trees with n vertices. What is B_n?
t*****j
发帖数: 1105
12
来自主题: JobHunting版 - How many full binary trees?
我这个算法可能不一定对,可能有些数算重复了。

我感觉这题应该用数学归纳法。
首先可以确定的是n一定要是奇数,偶数个数的n不存在full binary trees.
B(1) = 1
B(3) = 1
given B(n)
B(n+2): 实际上就是在B(n)个数上加两个节点。可以确定的是这两个节点一定是在一起
的。因为B(n)的所有节点都是偶数个小孩。要保持平衡只能加在同一个节点上。
所以这就是计算B(n)颗树总共有多少叶节点。总共有(n+1)/2个节点。因为每次的递
增都是只增加一个叶节点。
所以 B(n+2)=B(n)×(n+1)/2
然后算通式。。。
A binary tree is full if all of its vertices have either zero or two
children.
Let B_n denote the number of full binary trees with n vertices. What is B_n?
s**1
发帖数: 71
13
大家好
有道binary Tree 的题请教大家,generate all structurally distinct full binary
trees with n leaves, "full" means all internal (non-leaf) nodes have
exactly two children. For example, there are 5 distinct full binary trees
with 4 leaves each.
着重想问下 如何用DP解决呢?
多谢多谢!
h****n
发帖数: 1093
14
不需要vector吧,假设binary tree是complete binary tree
已通过online judge测试
/**
* Definition for binary tree with next pointer.
* struct TreeLinkNode {
* int val;
* TreeLinkNode *left, *right, *next;
* TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {}
* };
*/
class Solution {
public:
void connect(TreeLinkNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(root==NULL) return;
TreeLinkNode * cur = root;
TreeLinkNode ... 阅读全帖
h****n
发帖数: 1093
15
不需要vector吧,假设binary tree是complete binary tree
已通过online judge测试
/**
* Definition for binary tree with next pointer.
* struct TreeLinkNode {
* int val;
* TreeLinkNode *left, *right, *next;
* TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {}
* };
*/
class Solution {
public:
void connect(TreeLinkNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
if(root==NULL) return;
TreeLinkNode * cur = root;
TreeLinkNode ... 阅读全帖
p*****2
发帖数: 21240
16
玩竞赛对面试不利的一个地方就是面试经常遇到的数据结构比如LinkedList, Tree, 和
算法Binary
search,竞赛很少涉及到,因此一直心里都感觉到有些不安。
Binary search非常tricky,虽说道理简单,但是面试的时候却很容易出bug,因此总结
一下是必须的。假设i=0,
j=A.length-1, 我做了一下LeetCode上的所有binary
search的题目,发现了以下几点值得注意。
http://blog.sina.com.cn/s/blog_b9285de20101h88j.html
c********t
发帖数: 5706
17
你这个是full binary tree吧
complete要求是尽量full,但最后一层可以不满,但必须都靠左
A complete binary tree is a binary tree in which every level, except
possibly the last, is completely filled, and all nodes are as far left as
possible
这是一道编程题。
f*********m
发帖数: 726
18
来自主题: JobHunting版 - Unique Binary Search Trees的变形
leetcode 上的Unique Binary Search Trees,算总的Binary Search Trees数目:
Given n, how many structurally unique BST's (binary search trees) that store
values 1...n?
可以用dp:
int dp[n+1];
memset(dp, 0, (n+1)*sizeof(int));
dp[0] = 1;
dp[1] = 1;

for (int i = 2; i <= n; i++) {
for (int j = 0; j < i; j++) {
dp[i] += dp[j]*dp[i-j-1];
}
}
return dp[n];
若是要算总的Trees数目,那应该是
dp[i] += 2*dp[j]*dp[i-j-1]吧?
既一个节点既可以出现在根的左边,又可以出现在右边?
i**********e
发帖数: 1145
19
来自主题: JobHunting版 - 问一个leetcode上面binary tree的题目
这是问题给的 "Height-Balanced binary tree" 的定义:
“a height-balanced binary tree is defined as a binary tree in which the
DEPTH of the two subtrees of EVERY node never differ by more than 1.”
请重复读清楚问题至少三遍,然后再看看你画的图,你就明白了 :)
J****3
发帖数: 427
20
来自主题: JobHunting版 - 啥叫encode/decode binary tree啊?
OJ's Binary Tree Serialization:
The serialization of a binary tree follows a level order traversal, where '#
' signifies a path terminator where no node exists below.
Here's an example:
1
/
2 3
/
4

5
The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
J****3
发帖数: 427
21
来自主题: JobHunting版 - 啥叫encode/decode binary tree啊?
OJ's Binary Tree Serialization:
The serialization of a binary tree follows a level order traversal, where '#
' signifies a path terminator where no node exists below.
Here's an example:
1
/
2 3
/
4

5
The above binary tree is serialized as "{1,2,3,#,#,4,#,#,5}".
h*****u
发帖数: 109
s*******2
发帖数: 1182
23
来自主题: StartUp版 - 有人做hourly binary option吗?
今天看到有人在博客留言,挺高兴。在这里再 顶一下。
http://hboption.blogspot.com/
如果您同样对binary option trade 感兴趣的话,欢迎到我的博客讨论,建议、批评都
可。
因为华人讨论binary option的好像不多,所以就弄了个博客。如果您已有这方面成熟
的华人网站,博客, 俱乐部,请推荐一下,大家互相学习,共同提高。
其实我现在还只是停留在纸上谈兵阶段,一直 用demo account 模拟, 感觉还好。
关于Binary option, 正如前面有经验的前辈所讲到的, 由于普遍缺乏监管,导致
brokers 缺少诚信,scam 的行为太多,所以即使赚了钱想withdraw也难。还听说一个
人赚了几万,第二天一看账面没钱了,原来被公司程序员把程序给改了,赚的钱又赔了
进去。
所以就只好乖乖的,找个安全的broker, 像大家推荐的nadex. 它的资金好像相对安全
,但稍微有些繁琐,而且有 trade cost,输赢的幅度不是很大。
F****3
发帖数: 1504
24
来自主题: EmergingNetworking版 - 请问怎样把GeoIP的binary转换成CSV?
都不太好意思问,我是文科wsn,编程不懂。。真是委屈板上牛人了!
我希望把geoip的binary转换成csv文件或者任何其他sql语言可以读的形式,请问应该
怎么搞啊?我看了他们的说明书,一头雾水。好像是要先下个C 的API,然后在用
python什么的来读这个binary。
其实我干的事情很简单就是我有一列ip地址,我希望用binary data去他们背后是那些
机构。
谢谢牛人指个路啊!
I*******e
发帖数: 1879
25
☆─────────────────────────────────────☆
ganyaz (dk) 于 (Sat Jul 14 13:57:40 2007) 提到:
I am a beginner.
Is there any "readLine()" or similar methods for the reading of binary files
?
I mean to read binary and interprete them as floating point binary data.
Thanks!
☆─────────────────────────────────────☆
goodbug (好虫) 于 (Sat Jul 14 14:26:31 2007) 提到:
something like
FileInputStream fileinputstream = new FileInputStream(file);
int numberBytes = fileinputstream.available();
w****p
发帖数: 18
26
来自主题: Programming版 - how to implement binary tree efficiently?
Methods for storing binary trees
Binary trees can be constructed from programming language primitives in
several ways. In a language with records and references, binary trees are
typically constructed by having a tree node structure which contains some
data and references to its left child and its right child. Sometimes it also
contains a reference to its unique parent. If a node has fewer than two
children, some of the child pointers may be set to a special null value, or
to a special sentinel
f*******r
发帖数: 257
27
Generally there are two ways of deriving the models for binary data:
1. latent variable approach: y*=x \beta + u. Here y* is a continuous
latent variable. then u can be treated as logistically or normally
distributed, which corresponds to logit or probit model. This approach is
modeling the underline variable behind the binary variable y.
2. link function approach. This approach models the binary variable y
directly: y=g(X \beta), where g() is the inverse link function. Basically
it maps
b***k
发帖数: 2673
28
☆─────────────────────────────────────☆
timur (timur) 于 (Fri Oct 24 23:25:16 2008) 提到:
A portfolio is composed of a long binary call option with K=10 and a short
binary call option with K=20. The value of the portfolio is 16. Then what is
the value of the K=10 binary call?
☆─────────────────────────────────────☆
Jadeson (Jadeson) 于 (Sat Oct 25 00:00:28 2008) 提到:
我觉得求不出来,需要更多条件。
☆─────────────────────────────────────☆
timur (timur) 于 (Sat Oct 25 00:06:16 2008) 提到:
If we assume the
D***0
发帖数: 414
29
新人 求指教!非常感谢大家!
问题是这样的,
Team A's performance in Jan-Mar by month is 200 and in Apr-Dec is 250.
Team B's performance in Jan-Mar by month is 150 and in Apr-Dec, team B was
given a special treatment (while team A was not given that treatment) and
team B's performance in Apr-Dec by month was 250.
Team A is the control group and therefore the base/intercept is 200(team A's
performance in period 1).
Team B has a binary dummy variable (0/1) and the coefficient is 150-200=-50
Period 2 has a binary dummy ... 阅读全帖
P****l
发帖数: 156
30
来自主题: Statistics版 - 问一个 column-binary data 的问题
请问各位大牛,我知道 SAS可以读 column-binary data
但是有没有 不知道R或者python可不可以读column-binary data呢?
其实就是想吧 column-binary data 变成 ASCII的format。
谢谢各位了~~~
S*******l
发帖数: 4637
31
Gender is a spectrum.
今天真被震惊到了。看了佐治亚警察杀学生,注意到学生是gender non binary, 我就
糊涂了。吃饭的时候问一个实习的本科生,人家说很正常啊,他们入学的时候自己报性
别,有一些就是non binary, 称呼他们要用they, theirs, 不能用he, his or she her。
当然,她是私立liberal art学校的。认真讨论了一番。她说很多liberal父母是不会对
孩子强调孩子的性别取向的,甚至刻意避免替他们选择性别认定。
我脑子要炸掉了,第一次认识到,我和这个国家的新趋势,identity politics有多陌
生。
这个世界以后会是什么样子?
C**********n
发帖数: 100
32
是吗?
那如果我看到书上一个现成的binary search tree,
请问该按什么顺序输入这些数字才能使得所生成的binary search tree跟书上的那个一
样呢?
s**********r
发帖数: 141
33
来自主题: JobHunting版 - Discuss: A google binary search problem
I saw there's a long discussion on the following problem (I modified the
description a bit).
"给一个整数数组a[0...n],找出一个size k(1 distance中,使得其min distance 最大化 (max-mindist)."
It bothered me for a while (Simply I am not a DP fan). I consider it as a
binary search problem:
0. Sort the array in ascending order. O(nlogn)
1. If you claim the max-mindist is w, I can verify it in O(n).
2. Note that '0 <= w <= (a[n]-a[0])', you can try possible w's using
binary search.
3. Time comple
s******t
发帖数: 2374
34
a和b都是binary。
a+b 怎么算?
主要是有carry。我想了想不知道怎么弄才好。也不知道题目的要求,看起来是不能用
binary的加法运算符吧。
我觉得可能是类似与或门之类的?
c******f
发帖数: 2144
35
给个int 让你找它的binary表示里面的1的个数
我想到把它转成binary以后数多少个1就可以了
有没有什么用位操作之类的好办法可以让它更快?
感觉位操作这块很不熟悉 什么时候该和什么& | ~什么的
谁能给说说呢?
m****n
发帖数: 589
36
这个算的不是binary的
要是算binary,要%2 和/2的
c**********e
发帖数: 2007
37
来自主题: JobHunting版 - How many full binary trees?
A binary tree is full if all of its vertices have either zero or two
children. Let B_n denote the number of full binary trees with n
vertices. What is B_n?
s*********t
发帖数: 1663
38
你想个数,让小孩子猜,你告诉他大了还是小了,直到猜对,这就是个binary search呀
比如你想的是5, 小孩猜8,你告诉他太大,他下次如果猜1到8之间的,就说明他明白b
inary search思想,否则就是他的大脑还没发育
当然这个例子并不是二分的,他如果知道往范围的中间去猜,难就是个binary search
K******g
发帖数: 1870
39
来自主题: JobHunting版 - 初始化binary tree
写了个关于binary tree的代码,想测试一下。但是想来想去,不知道怎么随机生成一
棵binary tree,谁有什么好的建议吗?多谢。
r****o
发帖数: 1950
40
光用binary search我觉得搞不定吧,
因为duplicate可以出现在任何地方,而binary search的每一步会丢掉一半,这样可能
会把duplicate的元素丢掉。
r****o
发帖数: 1950
41
来自主题: JobHunting版 - 关于trie和binary search tree的疑问。
我对trie一直不是很懂,
如果要在n个单词中查某个单词(长度为m个字母)的话,
为什么不能把这n个单词组成一个binary search tree呢?这样平均复杂度是O(lgn)。
而用trie查的话复杂度是O(m)。
这样lgn 这个问题可能很弱,欢迎拍砖。
t******e
发帖数: 1293
42
linked list可以看作是只有右孩子的binary tree
有balance的算法,比如DSW,可以把它变为balanced binary tree
d***d
发帖数: 99
43
一道大公司诡异的complete binary tree max sum of 2 nodes 题
当场 40min white board 给出了O(N2) 的解法,对方表示赞许,但是没时间optimize
了。直觉告诉我应该有NlogN的解法。大牛指点下。
具体如下:
given one complete binary tree, with positive and identical values in all
nodes.
Find 2 nodes, such that:
sum of their path nodes to root (identical nodes will count only once) are maximum.
w******u
发帖数: 219
44
来自主题: JobHunting版 - full or complete binary tree的问题
比如huffman编码的那个查找树,就是full binary tree而不是complete binary tree.
b*****s
发帖数: 36
45
来自主题: JobHunting版 - 求教balanced binary tree的准确定义
我一直有个问题比较confused:
height-balanced 的定义到底是以下哪一种:
(1)Wikipedia上说:A balanced binary tree is commonly defined as a binary
tree in which the depth of the two subtrees of every node never differ by
more than 1。
(2)careercup书和Leetcode的balanced tree相关的题目上如此定义:A height-
balanced tree is a tree whose subtrees differ in height by no more than one
and the subtrees are height-balanced, too.
也就是说以下这个tree是符合(2)的要求而不符合(1)的要求。
1
/ \
2 2
/ \ / \
... 阅读全帖
c********t
发帖数: 5706
46
不用binary O(n^2) 可以输出结果数组。
用了binary,我只会求出最大长度 O(nlogn),无法输出最终结果数组,谁见过解法?
c********t
发帖数: 5706
47
不用binary O(n^2) 可以输出结果数组。
用了binary,我只会求出最大长度 O(nlogn),无法输出最终结果数组,谁见过解法?
m*******1
发帖数: 77
48
来自主题: JobHunting版 - Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.
The path may start and end at any node in the tree.
For example:
Given the below binary tree,
1
/ \
2 3
Return 6.
leetcode 上面的一道题,求大神们解释啊
e****e
发帖数: 418
49
来自主题: JobHunting版 - binary tree, sum of 2 nodes == given number
Binary tree 是暴力解法了吧.
Binary search tree is O(log(n)).
R**y
发帖数: 72
50
来自主题: JobHunting版 - Heapify a Binary tree
如何Heapify a Binary tree?
我google了一些资料,大部分的思路都是将binary tree 存储到一个数组,然后进行
heapify. 默认这个二叉树是用Node表示。
但是二叉树转换成数组的过程中,需要遍历两次这个树,第一次获得节点数目,第二次
存储节点。这就是2*O(n)了。
板上各位有没有其他的方法,直接在树本身上进行heapify?
谢谢各位
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)