由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Given a node of a tree, find all nodes on the same level
相关主题
两个有点难度很有意思的题MS的 on site面试,求bless
FLG面经:如何分块pre-order遍历一棵树?今天的一道电面题,有点意思
被VMWARE鄙视了(面经并求comment)一道老题目, 求最快捷解法
MS onsite 面经回馈本版 众小公司面经
G家电面面经--佛云了~~[合集] Google Phone Interview
一道linkedin的graph题一道面试题
贡献G电 估计挂了我恨iPhone@Facebook电面
python里面怎么表示树?Amazon面试题请教
相关话题的讨论汇总
话题: given话题: nodes话题: node话题: same话题: tree
进入JobHunting版参与讨论
1 (共1页)
C*Y
发帖数: 736
1
Interview questions for front-end web developer.
1. Given a node of a non-binary tree, find all nodes on the same level. Choose any
language and data structure you prefer to implement this.
2. Given a node of a DOM tree, find all nodes on the same level. Use javascript and jquery library to implement this, write as less code as possible.
j**l
发帖数: 2911
2
第一题的条件反射就是BFS?
r****o
发帖数: 1950
3
what is DOM tree?

Choose any
javascript and jquery library to implement this, write as less code as
possible.

【在 C*Y 的大作中提到】
: Interview questions for front-end web developer.
: 1. Given a node of a non-binary tree, find all nodes on the same level. Choose any
: language and data structure you prefer to implement this.
: 2. Given a node of a DOM tree, find all nodes on the same level. Use javascript and jquery library to implement this, write as less code as possible.

s*********t
发帖数: 1663
4
1, bfs
2, $(node).siblings()

Choose any
javascript and jquery library to implement this, write as less code as
possible.

【在 C*Y 的大作中提到】
: Interview questions for front-end web developer.
: 1. Given a node of a non-binary tree, find all nodes on the same level. Choose any
: language and data structure you prefer to implement this.
: 2. Given a node of a DOM tree, find all nodes on the same level. Use javascript and jquery library to implement this, write as less code as possible.

C*Y
发帖数: 736
5

1. bfs for sure.
2. siblings() is not correct. Tested with the following code:








  • 1

  • 2

  • 3




【在 s*********t 的大作中提到】
: 1, bfs
: 2, $(node).siblings()
:
: Choose any
: javascript and jquery library to implement this, write as less code as
: possible.

s*********t
发帖数: 1663
6
ah
forgot you want same level
well, same method
first call $(node).parent() till reach document root, finding the depth
then, n = $(document)
repeat n = n.children() 'depth'times, n is the list of nodes at the same
level

);

【在 C*Y 的大作中提到】
:
: 1. bfs for sure.
: 2. siblings() is not correct. Tested with the following code:
:
:
:
:
: