Data Structures and Algorithms of interview questions: Description of depth-first traversal and breadth-first traversal

Depth-first traversal starting from a vertex, this vertex first visit, then visit a neighbor node is not the first visit of the vertex, this vertex neighbor nodes continue to access and record the rest of the neighbors is not accessible when when a point adjacent to all vertices have been visited, a rollback vertex, adjacent to the non-access point as a vertex, this step is repeated until all nodes have been visited last.

Breadth-first traversal starting from a vertex, this vertex first visit, and then find out that all is not adjacent point of access nodes, access nodes after their first access to all the neighbors of these nodes, a repeat method until all nodes have been visited last.

Guess you like

Origin www.cnblogs.com/yichengming/p/11457058.html