What is the breadth-first traversal from the vertex F of a graph below? (visit nodes in ABC order if there are some nodes having the same selection ability)
4 phương ánCó giải thích
Các phương án trả lời
Chọn một phương ánLời giảiChọn phương án để mở
Đáp án đúng: "F, C, D, G, B, A, E, H". Duyệt theo chiều rộng dùng hàng đợi: thăm hết các đỉnh kề của đỉnh đang xét rồi mới đi xa hơn, các đỉnh ngang điều kiện lấy theo thứ tự chữ cái. Với các cạnh A–B, A–E, A–G, B–C, B–D, B–E, C–D, C–F, D–F, E–G, F–G: từ F nạp C, D, G nên dãy mở đầu F, C, D, G. Xét C, nó kề B, D, F, chỉ B là mới nên nạp B. Xét D, các đỉnh kề B, C, F đều đã có trong hàng. Xét G, nó kề A, E, F nên nạp A rồi E. Lấy ra lần lượt B, A, E. Bảy đỉnh đã xong, còn H cô lập nên phép duyệt khởi động lại ở H và H đứng cuối. "F, C, B, D, G, A, E, H" đưa B lên trước D và G, tức đi sâu từ C trước khi xét hết các đỉnh kề của F. "F, C, D, G, A, B, E, H" đặt A trước B, nhưng B được nạp từ C còn A nạp từ G, mà C ra khỏi hàng đợi trước G. "F, C, D, G, B, A, E" đúng mạch nhưng bỏ sót H.
Cùng phần 5
Suppose the graph G = (V,E) satisfies the conditions for the existence of an Eulerian cycle. The following is an algorithm for finding Euler cycle from the vertex X using stack:
declare a stack S of characters (a vertex is labeled by a character)
declare an empty array E (which will contain Euler cycle)
push the vertex X to S
while(S is not empty)
{ch = top element of the stack S
if ch is isolated then remove it from the stack and put it to E
else
select the first vertex Y (by alphabet order), which is adjacent
to ch,push Y to S and remove the edge (ch,Y) from the graph
}
the last array E obtained is an Euler cycle of the graph
Suppose a multigraph G is given below (view picture). Which of the followings is the Euler cycle from the vertex B, created by above algorithm?Có lời giảiCâu hỏiGiven the graph G = (V,E) and X is a vertex of G. Suppose there exists at least one Hamilton Cycle for the graph. The following is a backtracking algorithm for finding the first Hamilton cycle from the vertex X:
declare an empty array H (which will contain Hamilton cycle)
(1) Put the vertex X to H
(2) Check if H is a Hamilton cycle then stop, else go to (3)
(3) Consider the last vertex Y in H, if there is/are vertex(es) adjacent to Y, select the first adjacent vertex Z (by alphabet order) and put it to H. If there no adjacent vertex, remove Y from H and denote it as a bad selection (so you do not select it in the same way again).
Go to (2).
Suppose a G is given below (view picture). Which of the followings is the Hamilton cycle from the vertex A, created by above algorithm?Có lời giảiCâu hỏiWhat data structure is used for breadth first traversal of a graph?Có lời giảiCâu hỏiCả 48 câu của chủ đề48 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây