由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 报个电面面经,估计没戏了
相关主题
亚麻新鲜面经有人面过linkedin,比google amazon 题目怎么样?
A家面经 (三轮电面)A Google Problem
赞人品,也发Twitter 电面面经,又挂了!!(add Amazon 1st phone interview 面经)分享FB面筋
G intern电面面经Tree的traversal也分BFS和DFS?
uber 电面面经min depth binary tree用recursive解法一般能过关麽?
[面试题] 如何打印一个二叉树level by level?请教两道F面试题的follow up
MS onsite 面经面试归来,上面经回馈各位战友
fb电话面试为人父母,发面经,攒人品,求REFER
相关话题的讨论汇总
话题: dfs话题: level话题: print话题: tree话题: complexity
进入JobHunting版参与讨论
1 (共1页)
G****A
发帖数: 4160
1
都是大家熟悉的题
Q1, nth Fibonacci number. 要求尽可能多的解法。
follow-up, 每种解法的time/space complexity (要求function call的stack
overhead也看做space complexity).
Q2: c++基本概念。static, reference vs pointer, what is OOD, ...
Q3:列举并比较你常用的几种design patterns的作用和特点。
Q4: tree traversal, 要求level by level,按从底向上的顺序。同个level从左到右。
当我说要用DFS实现print by level的时候,此senior engineer先说“How could you
possibly print in level-order using DFS?”
解释完之后,senior engineer说:“ In the worst case, this will have
quadratic run time (if the tree is unbalanced). I was wondering about your
motivation to use DFS instead. It is quite a counter-intuitive
implementation.”
感觉是要被黑的套路,也就不想说什么了。尽管我记得以前推过:用DFS print in
level-order, average case 也是O(n).
update: 一点教训,尽量顺着面试官的思路说。这个小印senior在他认为“impossible
”的方法被证明“possible”之后态度明显有变化,变得很不nice。搞得我都开始犹
豫纠正不纠正他complexity分析的错误了。
F******F
发帖数: 63
2
Q4 用 dfs 是常见套路吧。此sr是啥意思?

you

【在 G****A 的大作中提到】
: 都是大家熟悉的题
: Q1, nth Fibonacci number. 要求尽可能多的解法。
: follow-up, 每种解法的time/space complexity (要求function call的stack
: overhead也看做space complexity).
: Q2: c++基本概念。static, reference vs pointer, what is OOD, ...
: Q3:列举并比较你常用的几种design patterns的作用和特点。
: Q4: tree traversal, 要求level by level,按从底向上的顺序。同个level从左到右。
: 当我说要用DFS实现print by level的时候,此senior engineer先说“How could you
: possibly print in level-order using DFS?”
: 解释完之后,senior engineer说:“ In the worst case, this will have

d**********x
发帖数: 4083
3
确实有点反直觉。。

you

【在 G****A 的大作中提到】
: 都是大家熟悉的题
: Q1, nth Fibonacci number. 要求尽可能多的解法。
: follow-up, 每种解法的time/space complexity (要求function call的stack
: overhead也看做space complexity).
: Q2: c++基本概念。static, reference vs pointer, what is OOD, ...
: Q3:列举并比较你常用的几种design patterns的作用和特点。
: Q4: tree traversal, 要求level by level,按从底向上的顺序。同个level从左到右。
: 当我说要用DFS实现print by level的时候,此senior engineer先说“How could you
: possibly print in level-order using DFS?”
: 解释完之后,senior engineer说:“ In the worst case, this will have

d**********x
发帖数: 4083
4
level order按直觉不应该是bfs吗。。

【在 F******F 的大作中提到】
: Q4 用 dfs 是常见套路吧。此sr是啥意思?
:
: you

l*****a
发帖数: 14598
5
什么厂?

you

【在 G****A 的大作中提到】
: 都是大家熟悉的题
: Q1, nth Fibonacci number. 要求尽可能多的解法。
: follow-up, 每种解法的time/space complexity (要求function call的stack
: overhead也看做space complexity).
: Q2: c++基本概念。static, reference vs pointer, what is OOD, ...
: Q3:列举并比较你常用的几种design patterns的作用和特点。
: Q4: tree traversal, 要求level by level,按从底向上的顺序。同个level从左到右。
: 当我说要用DFS实现print by level的时候,此senior engineer先说“How could you
: possibly print in level-order using DFS?”
: 解释完之后,senior engineer说:“ In the worst case, this will have

G****A
发帖数: 4160
6
嘿嘿。看来我2了。
主要感觉BFS要用一个额外的queue,而且从bottom level向上的方向对BFS来说不合适。

【在 d**********x 的大作中提到】
: 确实有点反直觉。。
:
: you

G****A
发帖数: 4160
7
东北的M

【在 l*****a 的大作中提到】
: 什么厂?
:
: you

l*********y
发帖数: 1431
8
还是用bfs,把结果放在stack里,然后再取出来不就是从底向上么?
他们有没有限制memory overhead?
c********t
发帖数: 5706
9
用DFS实现print by level,我只会先求depth, 然后传level = depth to 1,到dfs函数
来打印。那样肯定不能做到O(n) 应该是 O(n*depth) worst case O(n^2) 也没那个
engineer说的那么离谱吧。你说的O(n)怎么做?

you

【在 G****A 的大作中提到】
: 都是大家熟悉的题
: Q1, nth Fibonacci number. 要求尽可能多的解法。
: follow-up, 每种解法的time/space complexity (要求function call的stack
: overhead也看做space complexity).
: Q2: c++基本概念。static, reference vs pointer, what is OOD, ...
: Q3:列举并比较你常用的几种design patterns的作用和特点。
: Q4: tree traversal, 要求level by level,按从底向上的顺序。同个level从左到右。
: 当我说要用DFS实现print by level的时候,此senior engineer先说“How could you
: possibly print in level-order using DFS?”
: 解释完之后,senior engineer说:“ In the worst case, this will have

r**h
发帖数: 1288
10
如果二叉树是平衡的话
复杂度应该是1+2+4+8+...+N ~= O(2*N) = O(N)

【在 c********t 的大作中提到】
: 用DFS实现print by level,我只会先求depth, 然后传level = depth to 1,到dfs函数
: 来打印。那样肯定不能做到O(n) 应该是 O(n*depth) worst case O(n^2) 也没那个
: engineer说的那么离谱吧。你说的O(n)怎么做?
:
: you

相关主题
[面试题] 如何打印一个二叉树level by level?有人面过linkedin,比google amazon 题目怎么样?
MS onsite 面经A Google Problem
fb电话面试分享FB面筋
进入JobHunting版参与讨论
G****A
发帖数: 4160
11
http://leetcode.com/2010/09/binary-tree-level-order-traversal-u

【在 c********t 的大作中提到】
: 用DFS实现print by level,我只会先求depth, 然后传level = depth to 1,到dfs函数
: 来打印。那样肯定不能做到O(n) 应该是 O(n*depth) worst case O(n^2) 也没那个
: engineer说的那么离谱吧。你说的O(n)怎么做?
:
: you

l*****a
发帖数: 14598
12
想了一下,对层而言,确实可以用DFS.
print bt level by level的一个做法就是用dummy node,每次用前一次的结果
求这次的。。。
TreeNode dummy=new TreeNode();
dummy.next=root;
func(dummy.next);
public void func(TreeNode list){
//generate list of next level;
func(nextlist);
//print list of current level;
}
这个甚至是O(1)space 吧(不考虑callstack)

【在 c********t 的大作中提到】
: 用DFS实现print by level,我只会先求depth, 然后传level = depth to 1,到dfs函数
: 来打印。那样肯定不能做到O(n) 应该是 O(n*depth) worst case O(n^2) 也没那个
: engineer说的那么离谱吧。你说的O(n)怎么做?
:
: you

l*****a
发帖数: 14598
13
博士屯?

【在 G****A 的大作中提到】
: 东北的M
G****A
发帖数: 4160
14
positive

【在 l*****a 的大作中提到】
: 博士屯?
l*****a
发帖数: 14598
15

这个要求logn的解法了吗
you

【在 G****A 的大作中提到】
: 都是大家熟悉的题
: Q1, nth Fibonacci number. 要求尽可能多的解法。
: follow-up, 每种解法的time/space complexity (要求function call的stack
: overhead也看做space complexity).
: Q2: c++基本概念。static, reference vs pointer, what is OOD, ...
: Q3:列举并比较你常用的几种design patterns的作用和特点。
: Q4: tree traversal, 要求level by level,按从底向上的顺序。同个level从左到右。
: 当我说要用DFS实现print by level的时候,此senior engineer先说“How could you
: possibly print in level-order using DFS?”
: 解释完之后,senior engineer说:“ In the worst case, this will have

r**h
发帖数: 1288
16
log n是直接拿通项公式算的那个方法?

【在 l*****a 的大作中提到】
:
: 这个要求logn的解法了吗
: you

d**********x
发帖数: 4083
17
或者矩阵

【在 r**h 的大作中提到】
: log n是直接拿通项公式算的那个方法?
l*****a
发帖数: 14598
18
其实我认为问logn的就没什么意思了,就有点偏离CS了

【在 d**********x 的大作中提到】
: 或者矩阵
d**********x
发帖数: 4083
19
用通项还好吧

【在 l*****a 的大作中提到】
: 其实我认为问logn的就没什么意思了,就有点偏离CS了
l*******t
发帖数: 100
20
哦, 原来是马特拉伯啊

【在 l*****a 的大作中提到】
: 博士屯?
相关主题
Tree的traversal也分BFS和DFS?面试归来,上面经回馈各位战友
min depth binary tree用recursive解法一般能过关麽?为人父母,发面经,攒人品,求REFER
请教两道F面试题的follow upleetcode已刷五遍还没offer, LZ快绝望了。。。
进入JobHunting版参与讨论
c********t
发帖数: 5706
21
你这个难道不是bfs?
//generate list of next level; 要占空间的,就是push into queue啊

【在 l*****a 的大作中提到】
: 想了一下,对层而言,确实可以用DFS.
: print bt level by level的一个做法就是用dummy node,每次用前一次的结果
: 求这次的。。。
: TreeNode dummy=new TreeNode();
: dummy.next=root;
: func(dummy.next);
: public void func(TreeNode list){
: //generate list of next level;
: func(nextlist);
: //print list of current level;

l*****a
发帖数: 14598
22
不是啊,就是把pointer/refernce连在dummy后面

【在 c********t 的大作中提到】
: 你这个难道不是bfs?
: //generate list of next level; 要占空间的,就是push into queue啊

c********t
发帖数: 5706
23
嗯,多谢。
the best situation is balanced tree, O(n) 2N
the worst is unbalanced list like tree, O(n^2)
最鄙视那个senior,这种张嘴就拍,自以为是的人了。

【在 G****A 的大作中提到】
: http://leetcode.com/2010/09/binary-tree-level-order-traversal-u
c********t
发帖数: 5706
24
那我感觉会有问题啊,写一个试试吧。

【在 l*****a 的大作中提到】
: 不是啊,就是把pointer/refernce连在dummy后面
f********4
发帖数: 988
25
binary tree 那个。。
从下面来是不是可以把从上面来那个的result倒过来。。
我是指那个final result
这样答会被扁嘛。。
j********x
发帖数: 2330
26
dfs实现level order这种典型的奇巧淫技就不要说是啥常见套路了吧

【在 F******F 的大作中提到】
: Q4 用 dfs 是常见套路吧。此sr是啥意思?
:
: you

1 (共1页)
进入JobHunting版参与讨论
相关主题
为人父母,发面经,攒人品,求REFERuber 电面面经
leetcode已刷五遍还没offer, LZ快绝望了。。。[面试题] 如何打印一个二叉树level by level?
Palantir新鲜面经MS onsite 面经
print bst in level order dfs为什么是O(N)不应该是O(N^2)吗?fb电话面试
亚麻新鲜面经有人面过linkedin,比google amazon 题目怎么样?
A家面经 (三轮电面)A Google Problem
赞人品,也发Twitter 电面面经,又挂了!!(add Amazon 1st phone interview 面经)分享FB面筋
G intern电面面经Tree的traversal也分BFS和DFS?
相关话题的讨论汇总
话题: dfs话题: level话题: print话题: tree话题: complexity