由买买提看人间百态

topics

全部话题 - 话题: binary
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
c**y
发帖数: 172
1
来自主题: JobHunting版 - MS Onsite面经
Binary search works for an array with duplicate elements.
However, a modified binary search doesn't work for a rotated array with
duplicate elements (see Careercup book p181).
So how should we deal with a rotated array without duplicate elements?
Trying to use the modified binary search is good, but it is hard to remember
. We can first locate the special location, and then use the ordinary binary
search in the "right" range.
x****1
发帖数: 118
2
来自主题: JobHunting版 - G onsite面经
Google onsite归来,回馈本版,贡献一点面经和体会。记题的能力不是太好,就捡记
得住的说吧。废话不说,直接上题:
Phone screen:
先问了10道左右的小题,都是概念性的。
包括OOP,hashtable,BST,big O问题, 多线程,都是基本知识,没有什么tricky的地方。
有一道程序改错题,程序大概是替换一个字符串里面的pattern,不知道是谁写的,不是很
organized,估计是其他面试的同学的程序,我看了半天虽然觉的code写得很别扭,但也没找出什
么大错,面试官看我卡住了,就说我们继续吧。好在后来的题都答得比较顺利。
接下来又问了问现在做的项目,根据我的项目问了些问题,如server端如何实现session,项目中
有没有多线程,怎么实现。
最后还有5分钟结束的时候,给留了两道coding题,让我明早之前发给他。
一个就是binary search,不用多说了。
另外一个就是如何查找rotated sorted array (这也是很常见的题,因为面试官讲的是
cyclic,所以一开始我理解成{123456456},后来email问了才明白题意)... 阅读全帖
B*******1
发帖数: 2454
3
来自主题: JobHunting版 - 问个amazon面试题
What is Full binary tree and complete binary tree. And code to find if a
given tree is so.. (Phone interview, interviewer was very supportive. As I
couldn't finish coding, asked me to send offline, and did so).
问题很弱,但是怎么验证full binary tree和complete binary tree才是最快呢。
谢谢。
c****p
发帖数: 6474
4
来自主题: JobHunting版 - 代码写全对不容易
不要小瞧binary search。
binary search本身就不好写的。
而且正确无误的binary search代码好像是在binary search被提出若干年后才出现的。
p*****2
发帖数: 21240
5
来自主题: JobHunting版 - SDET与面经 (可能会比较长)
Z家电面
有人提到了Z。我就先聊聊Z。
Z没上市之前很火,我也就跟风申请了一把,看看到底什么情况。等了很长时间才有
recruiter联系我。当然有很大的原因是由于他们hiring freeze了当时。安排了一个电
面。电面大概30分钟这个样子吧。主要是问我的情况。然后问我给自己算法打多少分,
我打了8分。然后就问我知不知道什么是binary tree。我问是binary tree还是binary
search tree呢?他说你都说说吧。就简单讲了一下。然后就出了一个binary tree的问
题,我当时给出了一个答案,但是他说会有问题,我问为什么会有问题,他说也无所谓
了,够了。今天才看到这题在1337 code里有,我按照我的思路做了一下,是对的,没
什么问题。比较了一下1337的code,算法也差不多。
电面后recruiter问how it went? 我回答it went well。然后他也回信说对方也觉得
went well, 要安排onsite了。
k***t
发帖数: 276
6
来自主题: JobHunting版 - find treenode with two indegrees
看到一个题和一个答案。不太理解。
1.What does it mean that "tree representation is in Linked list format"?
Is there a standard way to represent a tree with a linked list? Or does it
just refer to the fact that TreeNode has left and right child link/pointers.
2. "When we thread a binary tree while doing preorder traversal, it wont
result in any cycle."
Is there a standard way to "thread' a binary tree? There is no "cycle"
concept at all in normal tree traversal, isn't it?
=======================================
S... 阅读全帖
r*********n
发帖数: 4553
7
0:aa
1:aabbccaa
2:bb
3:bbc
4:bbbbbb
5:cc
6:ccbb
比如你要判断A = aabbccaa能否由其他词组成:
A[0] = a,所以你在所有words里面做binary search(with respect to the first
char),你发现arr[0],和arr[1]是由char a开头的
然后在[0,1]里面binary search A[1] = a(with respect to 2nd char),你还是得
到[0, 1],这个时候因为arr[0]只有2个char,所以你发现arr[0]是A的prefix。
然后在[0 - 6]里面binary search A[2] = b(with respect to 1st char),你得到[
2,3,4]
然后在[2,3,4]里面binary search A[3] = b(with respect to 1st char),你得
到[2,3,4]....
整个思路和MSD string sort是一样的,解释起来比较verbose,你理解了MSD sort,也
就理解这个算法... 阅读全帖
T******7
发帖数: 1419
8
//==========================================================================
==
// 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.
//
//==========================================================================
==
#include
using namespace std;
/**
* Definition for binary t... 阅读全帖
w********p
发帖数: 948
9
来自主题: JobHunting版 - 亚麻三面面经,攒人品,求好运
3. 继续判断这个二叉树是不是平衡树
A balanced binary tree is commonly defined as a binary tree in which the
depth of the two subtrees of every node differ by 1 or less,[3] although in
general it is a binary tree where no leaf is much farther away from the root
than any other leaf. (Different balancing schemes allow different
definitions of "much farther".[4]) Binary trees that are balanced according
to this definition have a predictable depth (how many nodes are traversed
from the root to a leaf, root counting ... 阅读全帖
l*****a
发帖数: 14598
10
来自主题: JobHunting版 - BST 找重复节点数
In computer science, a binary search tree (BST), which may sometimes also be
called an ordered or sorted binary tree, is a node-based binary tree data
structure which has the following properties:[1]
The left subtree of a node contains only nodes with keys less than the node'
s key.
The right subtree of a node contains only nodes with keys greater than the
node's key.
Both the left and right subtrees must also be binary search trees.
There must be no duplicate nodes.
j**7
发帖数: 143
11
来自主题: JobHunting版 - TripAdvsior 面经 (完败)
phone #1: Given the head node of a singly linked list of characters, write
an efficient program to remove all nodes containing vowels.
phone #2: Given a character array (char[] input) that contains "words"
separated by spaces, create a function to reverse the words in the array.
For example, given ['H', 'i', ' ', 'W', 'o', 'r', 'l', 'd'] produce ['W', 'o
', 'r', 'l', 'd', ' ', 'H', 'i']. For the purposes of this problem the input
will contain only letters and spaces. Be sure your solution tolera... 阅读全帖
c**y
发帖数: 73
12
来自主题: JobHunting版 - 狗狗家onsite面经
1)给的一个double linkedlist,给定一个array,包含若干double linkedlist的节点
的地址,统计这个array包含的互相独立部分的数目。用例子说明吧。
一个double linkedlist是A<>B<>C<>...<>X<>Y<>Z(一共26个节点,从A到Z)。
如果array是{A,Z},那个return 2,因为A和Z两个不相邻的。
如果array是{A,B,D},那个return 2,因为AB是一个部分,D是另外一个独立的部分。
如果array是{A,B,C,。。。,Y,Z},那么return 1,因为AtoZ是一个独立的部分。
2)从给定的sorted的array如何build的一个balanced的binary tree?
开始给了一个recursive的方法,后来要一个iterative。
iterative的解法:
a.先建立一个空的balanced binary tree
建立这个空的balanced binary tree的方法可以参见如何用array来表示一个heap的方
法。具体是对于节点i,它的left和right child... 阅读全帖
J****3
发帖数: 427
13
In computer science, a binary search tree (BST), sometimes also called an
ordered or sorted binary tree, is a node-based binary tree data structure
which has the following properties:[1]
The left subtree of a node contains only nodes with keys less than the node'
s key.
The right subtree of a node contains only nodes with keys greater than the
node's key.
The left and right subtree must each also be a binary search tree.
There must be no duplicate nodes.
Wiki
w******j
发帖数: 185
14
http://discuss.leetcode.com/questions/49/binary-tree-level-orde
Complexity Analysis:
Although the DFS solution traverse the same node multiple times, it is not
another order slower than the BFS solution. Here is the proof that the DFS
solution above runs in O(N) time, where N is the number of nodes in the
binary tree and we assume that the binary tree is balanced.
We first compute the complexity of printLevel for the kth level:
T(k) = 2T(k-1) + c
= 2k-1 T(1) + c
= 2k-1 + c
Assuming it'... 阅读全帖
p****n
发帖数: 69
15
来自主题: JobHunting版 - 就差一点了,接着求祝福
送20个包子。
在版上求祝福果然有用,上次面的金融小公司要求再onsite一次,这次要见一个
partner,希望是一个好兆头(其实第一次也见了一个,全程面无表情)。
同时为最近一家投行的面试求祝福,这次面试挺顺的,感觉技术和非技术问题都处理得
当,现在就看有没有化学了。
同时(稍微贪心一下),希望下周能顺利拿到两个onsite,一个是很quant的职位,一
个是一家startup的程序员。
之前fail掉很多面试,都是倒在最后一刻,希望这次能走完这最后一点路程。
这里送上一些Twitter data scientist的面经。
第一轮网上做题,一个小时两道题:
1. find the largest binary gap of an integer. binary gap is defined as the
number of contiguous 0 bits between two 1 bits.
E.g.
0x89 has binary representation of 10001001, which has two binary gaps, one =
3, the oth... 阅读全帖
A*********c
发帖数: 430
16
有意思,想想。胡说一下啊。
先做一次binary search,找到lower bound。看前面有几个元素,然后把生成数加几。
然后没完,更新binary search的lower bound继续search,重复,直到binary search
返回的结果是-1为止。如何?
binary search外面套一层。
m****n
发帖数: 25
17
来自主题: JobHunting版 - 新鲜G面经
四个方向dfs的话就需要traverse所有黑格吧
binary search是对边界做?比如我从(x,y)黑出发对边界(0,y) binary search,
那我考察(x/2, y),
但如果是环的话,(x/2,y)如果是白,那么(x/2-1,y)也可能是黑啊
似乎感觉能构造一个worst case..
使得每次binary search踩中白点...那样binary search的优势就没法体现了...
r*******2
发帖数: 104
18
一周之内面了微软两个组,刚刚收到结果双双悲剧,一个组的HR说It's a tough call
,另一个组的HR说very close,不知道是不是套话,总之很沮丧……来版上求问一下大
家问题可能出在哪,并且附上大概的面试过程和coding题目。
第一组:
第1轮:是一个SDE II,看名字像是中东人。coding题目是给定2棵树,判定是否其中一
棵是另一棵的subtree,同时用了DFS和BFS,写完code讨论了几个testcases和复杂度就
结束了。
第2轮:一个白哥Senior Lead,问的题目是一个maze(用2D matrix表示,有的坐标上
有障碍),给定起点和终点,找出从起点到终点的path,还是用的常规的DFS解法,搜
索过程排除有障碍的和访问过的坐标。
第3轮:一个小黑Lead II带去一起lunch,午饭之后问了大概半小时设计题,设计当软
件窗口(比如Word窗口)大小变化的时候每个子图标栏的大小如何变化,大概定义了一
下各个class,挑了其中一个function写了code。
第4轮:一个三哥Principle Lead,先问了一个ASCII和Kanji字... 阅读全帖
l****i
发帖数: 2772
19
来自主题: JobHunting版 - yahoo onsite
今天onsite,前三个面试官都是三哥。
被第二个三哥问晕了。问了我3道题。有一题是一个DP,白板写了。其他2个问题,跪了。
1.
问:无限数据流里,sample出k个。
答:reservoir sampling
问:解释一下这个算法
答:blabla
问:这个算法取每个数据的概率不一样,不可以
答:这是个经典算法,有paper证明过这个
问:好,那你现在证明一下这个算法
没研究过这个算法的证明,当场跪了。三哥坚持reservoir sampling是错误的。没办法
,我给了另外一个解法,每个data算一个random score,用heap保持score高的k个。
2.
问:给你一个binary tree,换成linked list
答:我问,是普通的binary tree? 不是BST?
问:就是最普通的任意binary tree
答:可以inorder走一遍,转换成linked list,返回inorder的第一个node作为list的
head
问:变成linked list后,怎么reconstruct回原来的binary tree。要求in place。
答:!#%&(,跪... 阅读全帖
a********r
发帖数: 217
20
来自主题: JobHunting版 - Groupon电面
面的是Relevance algorithm engineer职位,两题,烙印面试官,估计挂了。
第一题,是给定array of int,A, 均匀分布到n个buckets,每个buckets里面的数目
是多少。基本就是bucket sort,思路比较容易,找出max 和min, 然后分割为n个
buckets,统计每个bucket里面个数。
第二题,是第一题的一个延伸,问如果每个buckets的上下届是给定的,怎么来求每个
buckets里面的count的。
例如,array A is
1, 200, 52, 2, 4, 1003
bucket的范围为,
1---100
101-- 1000
1001--2000
那么就等价于给你一个range vector, 表示每个bucket的下界, i.e. {1, 101, 1001}
问此时怎么求每个bucket里面元素的个数。
我当时的想法是,对每个array 里面的number,做binary search找出它属于那个
bucket,然后count,然后感觉是不是要sort array,会有帮助,讨论了一会儿,只是
意识到sort ... 阅读全帖
f********a
发帖数: 165
21
来自主题: JobHunting版 - serialize n-ary tree 一问
是的,这是serialize binary tree.我的意思是要么binary tree不是n-ary tree的一
个特例,不然用geeksforgeeks链接里的方法得不到binary tree的正确序列化。但是链
接里又提到n-ary tree是binary tree的延伸,所以有些confused了。
a*******g
发帖数: 1221
22
来自主题: JobHunting版 - 问一个多次遇到的面试题
最好的结果就是binary searchhttps://www.quora.com/Search-Algorithms-Why-cant-
there-be-an-algorithm-faster-than-binary-search
不过有一种叫interpolation search的利用插值,可以在数据均匀的情况下更快,但也
可能更慢。你可以设计一种新的算法,把binary search和interpolation search结合
起来。很插值,插几轮效果不好,就去binary.

n
t******l
发帖数: 10908
23
来自主题: Parenting版 - 数学家出的智力题
如果岛上所有人都是棕色眼镜,也就是外国游客说的话是错的,根据时间起点一样可以
所有人都翘翘。
我觉得你的隐含假设是 logistician 只限于 “通常意义上的” simple binary
logics expression,但其实这个跟 counting days 是自相矛盾的,因为 counting
days 不是 “通常意义上的” simple binary logics expression。。。
如果你扩展 “通常意义上的” simple binary logics expression,那就没有理由不
能存普朗克常量。。。也就是不限于 “通常意义上的” simple binary logics
expression 的话,罗素说你就不能排除 deterministic-abstract-machine。

:老掉牙的题了,推理很简单。不过为啥游客说的不是废话呢。简单一点,假设只有三
个蓝眼睛。
:命题一,每个人都知道存在蓝眼睛
w***w
发帖数: 6301
24
来自主题: Stock版 - 大家说说twm
I have mantal stop.
You will see later when market turn direction how I respond.
And you can also trade binary option for some time and then you will
understand, compared with binary option, emini is like a paper trading.
I traded emini for 4,5 years and then options for a couple of years, before I traded binary option.
Trade some binary option and you can easliy understand me.
Let me do some market reading: the current bull run need a big up day to
bring a meaningful pullback. If I don't see th... 阅读全帖
h***a
发帖数: 1773
25
【 以下文字转载自 JobHunting 讨论区 】
发信人: repeat112 (windfantasy), 信区: JobHunting
标 题: 微软onsite面试悲剧,附面经并求分析,多谢~
发信站: BBS 未名空间站 (Thu May 8 18:31:09 2014, 美东)
一周之内面了微软两个组,刚刚收到结果双双悲剧,一个组的HR说It's a tough call
,另一个组的HR说very close,不知道是不是套话,总之很沮丧……来版上求问一下大
家问题可能出在哪,并且附上大概的面试过程和coding题目。
第一组:
第1轮:是一个SDE II,看名字像是中东人。coding题目是给定2棵树,判定是否其中一
棵是另一棵的subtree,同时用了DFS和BFS,写完code讨论了几个testcases和复杂度就
结束了。
第2轮:一个白哥Senior Lead,问的题目是一个maze(用2D matrix表示,有的坐标上
有障碍),给定起点和终点,找出从起点到终点的path,还是用的常规的DFS解法,搜
索过程排除有障碍的和访问过的坐标。
第3轮:一个小黑... 阅读全帖
v*****u
发帖数: 1796
26
//comfort 应该是真的close,要不然老大不会花时间的吧。好好准备,拿个比软
软好的offer

【 以下文字转载自 JobHunting 讨论区 】
发信人: repeat112 (windfantasy), 信区: JobHunting
标 题: 微软onsite面试悲剧,附面经并求分析,多谢~
发信站: BBS 未名空间站 (Thu May 8 18:31:09 2014, 美东)
一周之内面了微软两个组,刚刚收到结果双双悲剧,一个组的HR说It's a tough call
,另一个组的HR说very close,不知道是不是套话,总之很沮丧……来版上求问一下大
家问题可能出在哪,并且附上大概的面试过程和coding题目。
第一组:
第1轮:是一个SDE II,看名字像是中东人。coding题目是给定2棵树,判定是否其中一
棵是另一棵的subtree,同时用了DFS和BFS,写完code讨论了几个testcases和复杂度就
结束了。
第2轮:一个白哥Senior Lead,问的题目是一个maze(用2D matrix表示,有的坐标上
有障碍),给定起点和终点,找... 阅读全帖
L*****e
发帖数: 8347
27
来自主题: Apple版 - Surface 32GB只有16GB可用
我们一般讲的多少G是decimal size,而系统报的是binary size.
1G(in decimal) = 0.93G(in binary)
32G(in decimal) = 29G(in binary)
64G(in decimal) = 59G(in binary)
2G就是这么差出来的。。。
windows RT, Office, 还有其它build-in apps占了8G
预留的recovery空间5G
所以29G - 13G = 16G; 59G - 13G = 46G
d**k
发帖数: 1223
28
来自主题: Java版 - 问一个关于pdf的问题
日!这下完犊子了! 存成文件也打不开,adobe说什么文件类型不支持什么的。我做了个
测试,找了个pdf文件,然后给读成binary,存到数据库里,发现数据都是
0x25:50:44:46:2d........, 跟从access里来的就不一样。
从数据库里把binary code 的开头儿一部分放到一个hex converter 里,再转化成
ascii, 结果就是%PDF-。
用同样的办法把access里来的binary 放进去一看,狗屁都不是。
我估摸着这个binary code可能只有access 自己用个什么内置的东西读出来吧?换个地
方就不灵了。有什么办法能转化一下吗?谢谢了
X****r
发帖数: 3557
29
来自主题: Programming版 - why use static function here?
I don't think you can overload operator + as a static member.
Quote:
13.5.2 Binary operators [over.binary]
1 A binary operator shall be implemented either by a non-static member
function (_class.mfct_) with one parameter or by a non-member function
with two parameters. Thus, for any binary operator @, x@y can be
interpreted as either x.operator@(y) or operator@(x,y). If both forms
of the operator function have been declared, the rul
s*****j
发帖数: 6435
30
filtering your DAPI signal (mean or median, "Process"->"Filter")
threshold to mask, "Image"->"Adjust"->"threshold"
get rid of holes in DAPI. "Process"->"Binary" -< "Fill Holes"
if needed, watershed to seperate attached DAPI ROI "Process"->"Binary"-?"
watershed"
use partical analyzer to add all DAPI ROIs in the ROI manager "Analyze"->"
Analyze partcles"
use "Process"-"bianry"-> "dilate"/"erode" to get outer region of nuclear.
set parameters in "Process"->"binary"->"options" on how you want to "s... 阅读全帖
s*******r
发帖数: 63
31
thanks a lot.
what about the first question:
how do you synthetically create binary put options from binary call
options?
from wiki, it says "CBOE only offers calls, as binary put options are
trivial to create synthetically from binary call options."
I'm wondering how.

and
f***a
发帖数: 329
32
来自主题: Statistics版 - 问个面试问题
回来了回来了。
重新想了下,这个其实就是在一堆iid variables之间加了一个constraint。貌似
sample起来不难。
以最简单的n=2,m=1为例:
Without constraint, outputs space is {(0,0),(0,1),(1,0),(1,1)}.
The corresponding probability space is {(1-p1)*(1-p2), ..., p1*p2}.
With constraint, outputs space is O={(0,1),(1,0)}.
The corresponding probability space is P={(1-p1)*(p2), p1*(1-p2)}.
Under the constrain, standardize the probability space into
P.std={P1/(P1+P2),P2/(P1+P2)}.
Then under constrain, output (0,1) has the probability P1/(P1+P2) to be
sam... 阅读全帖
f***a
发帖数: 329
33
来自主题: Statistics版 - 问个面试问题
回来了回来了。
重新想了下,这个其实就是在一堆iid variables之间加了一个constraint。貌似
sample起来不难。
以最简单的n=2,m=1为例:
Without constraint, outputs space is {(0,0),(0,1),(1,0),(1,1)}.
The corresponding probability space is {(1-p1)*(1-p2), ..., p1*p2}.
With constraint, outputs space is O={(0,1),(1,0)}.
The corresponding probability space is P={(1-p1)*(p2), p1*(1-p2)}.
Under the constrain, standardize the probability space into
P.std={P1/(P1+P2),P2/(P1+P2)}.
Then under constrain, output (0,1) has the probability P1/(P1+P2) to be
sam... 阅读全帖
s**f
发帖数: 365
34
请问如何在SAS里计算:
是survey data,如何用SAS计算两个var的correlation和这个correlation的
confidence interval?
这两个variable可能是:
binary VS binary
binary VS continuous
binary VS ordinal
如果不是survey data的话,用PROC CORR或者PROC FREQ都能算。不过我这个data有
strata,weight,看了半天文献也没找到如何计算confidence interval。
感谢!
p**z
发帖数: 65
35
没人发帖好冷清。我来发几个平时用Python攒的小窍门吧。笔记是英文的懒得翻译了
Python tips: binary, octal, and hex numbers
To use literal values in binary, octal, or hex (works since Python 2.6):
binary: 0b1111
octal: 0o105
hex: 0xffff
To convert an input string that is the representation of a number in a
specific base to an integer:
int('1111', 2)
int('105', 8)
int('ffff', 16)
To output the string representation of a number in a specific base:
If converting to binary, numpy.binary_repr() is the most efficient
If converting to any b... 阅读全帖
b********n
发帖数: 38600
36
来自主题: Military版 - Ching-Chong Ding-Dong
1. Ching Chong
The only word arrogant non-Asians think all Asians say.
White Kid: Hey, what does ching chong mean?
Asian Kid: It means go fuck yourself.
2, ching chong
The only to two phonetics composing the chinese language. Comparable to the
1 and 0 binary language system of a computer.
Examples:
In binary: 100110
In chinese: ching chong chong ching ching chong
Hello. How are you doing today sir? It's a nice day outside. Wouldn't you
agree?
Binary: 10
Chinese: ching chong
m**********e
发帖数: 12525
37
http://relativity.livingreviews.org/Articles/lrr-2006-3/downloa
第73页
结论:
为什么说这是binary黑洞融合产生的引力波?
答案很简单,LIGO传感器configuration设计上只能用来探测这一质量范围的binary黑洞
融合产生的引力波
那么为什么ligo传感器要这么设计?
因为巨大质量产生的引力波强度虽然大,但是波长太长,超越太阳系尺寸,无法测量.
质量过小产生的引力波强度太弱,低于人类技术下限
目前勉强有能力探测的,只有这么一个质量范围内binary黑洞融合产生的引力波,所以
ligo振子设计上严格准对了这类目标
clear?
Q**********u
发帖数: 1616
38
有个人的对讲机只有一个频道
他在对讲机收到信号之后就推断信号的来源就只发送那个频率的信号
其实信号来源可能在很多个频率都发了信号

http://relativity.livingreviews.org/Articles/lrr-2006-3/download/lrr-2006-3Color.pdf
:第73页
:结论:
:为什么说这是binary黑洞融合产生的引力波?
:答案很简单,LIGO传感器configuration设计上只能用来探测这一质量范围的binary黑
洞融合产生的引力波
:那么为什么ligo传感器要这么设计?
:因为巨大质量产生的引力波强度虽然大,但是波长太长,超越太阳系尺寸,无法测量.
:质量过小产生的引力波强度太弱,低于人类技术下限
:目前勉强有能力探测的,只有这么一个质量范围内binary黑洞融合产生的引力波,所以
:ligo振子设计上严格准对了这类目标
:..........
t******l
发帖数: 10908
39
来自主题: Military版 - 质数是不是最没用的数学概念
当然 cantor diagonal argument 还是补充说明一下以防误解。
cantor diagonal argument 里面的无限序列上的 permutation 本身,马工还是有对付
的办法的。。。比如如果拿 0 和 1 的序列做例子,从第一位上有两个 choice,选好
第一位以后,第二位再有两个 choice,这样马工可以画出一个无限深度的 binary (
decision) tree。。。在这个无限深度的 binary tree 上面,虽然马工不可能做
depth first traversal,但是做 breadth first traversal 还是可以的,所以该无限
深度的 binary tree 本身(只要不去 collect leaf node 先),还是可以 linear
ordered 毫无压力的。
但 cantor 的问题,是要把所有的 leaf node 给收集到一个集合里,再做个 diagonal
argument。。。对于这天顶星的一小步,地球马工蹦蹦机彻底没辙了。。。于是香浓
也只能骂娘。。。

cut
s***h
发帖数: 487
40
因为众所周知 “女生的心思很难猜”,所以为了保证 project 成功,limit project
scope:“猜心思” predictor 太难了,实际点,binary classification:to 追, or
not to 追。就直接出货了。
当然 binary classification 常常不是很 smooth,于是会发生前面说的 “一分钟前
热情似火,一分钟后走人了” 的这种情况 。。。 但 funding 不够也就不要希望太多
了 。。。


: Binary or binomial classification is the task of classifying the
elements of

: a given set into two groups (predicting which group each one belongs
to) on

: the basis of a classification rule.

: https://en.wikipedia.org/wiki/Binary_classification... 阅读全帖
j*********r
发帖数: 24733
41
Critics Attack Mother’s Day as ‘Offensive’ Because It’s A ‘Gendered
Holiday’
This was inevitable: Social-justice warriors are now saying that Mother’s
Day is gender-exclusionary.
Writing in the Toronto Star, columnist Emma Teitel says that such “gendered
holidays” are “generally a drag for non-binary parents who don’t
identify with a single gender.”
There’s even a proposed “Non Binary Parents Day” (July 17), Teitel notes.
But she has a different idea: Getting rid of both Mother’s and Father’s
Da... 阅读全帖
k*k
发帖数: 49
42
来自主题: JobHunting版 - How to serialize and deserialize
1) binary tree
serialize:
pre-order unambiguous form:
(r (r_left) (r_right (r_right_l) ()))
a recursive implementation is much easier than iterative version.
de-serialize:
scan from left to right, use stack for temporary recording, when ')' is
encountered, pops to the previous '(' and generate node accordingly.
2) binary graph
what is the definition of a binary graph?
s****t
发帖数: 36
43
来自主题: JobHunting版 - google 电面
刚刚面的电面,心里没底啊。
1. Given a sorted integer array and a specific integer, find the
first position of that integer. Array contains lots of
duplicate.
我说用binary search, 找到之后然后左移找到第一个于它前一个不一样的,就是
first position。然后他说如果有很多很多的duplicate的话,有没有更快的方
法。然后我就想先binary search找到了middle之后,再在left和middle之间进行
多一次binary search,用一些边界条件什么的判断。 这样算不算改进啊,我觉得应
该是会快点啊。
2. 有很多doc,里面有很多电话,怎么查找电话。
我说只是一次用的,hash一下找,如果以后还得用的话,就sort他们,然后按area
code做一个B tree什么的。
3. 在一个resume里面找电话。
我说如果是US的话找一个连续是10个digit的,或者中间有()或-的,然后查头三个
digits是不是va
f****4
发帖数: 1359
44
来自主题: JobHunting版 - bloomberg电面
binary tree和binary search tree区别
only binary search tree has
left child < parent < right child
k**********i
发帖数: 177
45
来自主题: JobHunting版 - 刚面完 google,题目
晚了半个小时才打电话。。。
是个三哥, 英语很是费解, 不停的i am sorry, excuse me。。
接下来问了project 的东西, 问的很详细,就不多说了,
然后是个算法题,
给一个rotated sorted array,
例如: 3 4 5 1 2
然后给一个数 例如 6, 然后去找他是否在array里面。
我首先说是找到分界点, 然后对两边用binary search, 这个效率应该是O(n)吧, 毕
竟最坏情
况下找到分界点要遍历一遍。
然后他就问binary search 为啥不写成recuisive的, 然后问recursive和平常的有啥
区别。。。
然后他问怎么能够提高算法的效率, 我说能到logn。。。就跟就是用binary和递归每
次找中点。
。。
bless自己了。
j**l
发帖数: 2911
46
就以binary search来说,很容易。
但是也不容易在白板上写好。特别是一些变体,比如有重复元素是返回任意一个,第一
个还是最后一个。比如a1 < a2 < a3 < a4 < a5 < a6 < a7 < a8, 给一个数x, a6 < x
< a7, 如何正确返回a7(第一个恰好比x大的元素)。这些都对下面的写法很有讲究。
lower = center + 1还是lower = center?
upper = center - 1还是upper = center?
编程珠玑就举出了一个很好的例子,因为lower, upper的更新没写好,导致程序死循环。
就连经典的书Programming Interview Exposed, 也没有很完美的写好binary search.
相比之下,编程珠玑上的binary search写的更好。
事实上,题目越是容易,面试官的要求也就更严格。
r****o
发帖数: 1950
47
来自主题: JobHunting版 - 问一道google面试题(from careercup)
想了一下,好像可以达到O(nlgn). 假定数组为 a[1]...a[n]。
先排序 O(nlgn)
然后用binary search 找a[i],过程如下:
对于a[mid],如果a[n]+a[n-1]也比T-a[mid]小,说明a[mid]选值过小,故在右半边继续找a[mid];如果a[1]+a[2]也比T-a[mid]大,说明a[mid]选值过大,则应在左半边继续找a[mid],
继续该binary search,一直找到a[mid],使得a[1]+a[2]<=T-a[mid]<=a[n-1]+a[n],
然后可以线性查找出i,j,使得a[i]+a[j]=T-a[mid]。
binary search共需O(lgn)步。线性查找O(n)。
总复杂度还是O(nlgn)。
希望大家对我的想法多提意见。
m*****g
发帖数: 226
48
来自主题: JobHunting版 - amazon一道面试题
是否可以这样递归
如果n node form T(n) binary trees,
T(n+1) 便在T(n)上面加一个。
从most unbalanced binary tree, n nodes, n possible positions to add
到most balanced binary tree, n nodes, 0 possible positions to add
是不是T(n+1)=T(n)+(n-1+n-2+...+1)
这样搞?
s********l
发帖数: 998
49
来自主题: JobHunting版 - Amazon 三次电面面筋
bless lz~
"serialize and re-construct binary tree. (coding, read to him)"
这个是 给个binary tree 然后变成link list 然后再重建原来的binary tree?
f*********5
发帖数: 576
50
来自主题: JobHunting版 - 请教一个常见的面试题的答案
why?
for example.sizeof(a)=8
lo=0,hi=8 //lo mean start index of binary search
// hi means end index of binary search
mid=(lo+hi)/2;
when u found that a[mid]=mid
u don't need to check a[0]..a[mid-1]...
then u can use binary search...
make sense?
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)