You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
html结构如下:
<divclass="parent"><divclass="child-1"><divclass="child-1-1"><divclass="child-1-1-1">
a
</div></div><divclass="child-1-2"><divclass="child-1-2-1">
b
</div></div><divclass="child-1-3">
c
</div></div><divclass="child-2"><divclass="child-2-1">
d
</div><divclass="child-2-2">
e
</div></div><divclass="child-3"><divclass="child-3-1">
f
</div></div></div>
深度优先遍历和广度优先遍历
这两个名词出现于一种叫做图的数据结构中,是两个遍历探索的算法:
深度优先
广度优先
顾名思义,对顶点A的未被访问过的领节点进行探索,然后继续探索未被探索的领节点的领节点,可以理解为逐层探索,直至这一层被探索完毕,探索下一层,往复上述操作,直至全部探索完毕
访问过程:
个人理解:
实现的方法有很多,这里我就直接套用atheist1的实现方法啦,从答案就能很清晰的看出深度优先和广度优先的区别~
再次申明,代码来自atheist1
深度优先:
广度优先:
The text was updated successfully, but these errors were encountered: