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 | | 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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:
【在 s*********t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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 的大作中提到】![](/moin_static193/solenoid/img/up.png) : : 1. bfs for sure. : 2. siblings() is not correct. Tested with the following code: : : : : :
| |