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

5 phương ánCó giải thích
Đề bài
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

Đề bài
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

Đề bài
}

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ác phương án trả lời

Chọn một phương án
Lời giảiChọn phương án để mở
Đáp án đúng: "B, D, C, B, A, B". Đa đồ thị có hai cạnh song song B–A cùng các cạnh B–C, B–D và C–D; bậc của A, C, D là 2 và của B là 4, đều chẵn nên chu trình Euler tồn tại. Chạy thuật toán từ B: B chưa cô lập, láng giềng đầu theo chữ cái là A nên đẩy A và bỏ một cạnh B–A; tại A còn cạnh B–A thứ hai nên đẩy B và bỏ cạnh đó; tại B còn C và D, chọn C rồi bỏ B–C; tại C còn D nên đẩy D và bỏ C–D; tại D còn B nên đẩy B và bỏ D–B. Giờ B đã cô lập nên các đỉnh lần lượt bị lấy khỏi ngăn xếp và ghi vào E: B, D, C, B, A, B. Phương án "B, A, B, D, C, B" chính là đường đi lúc đẩy vào, chưa qua bước lấy ra, mà E được dựng từ chiều lấy ra nên là đảo của nó. Phương án "B, C, D, B, A, B" hợp lệ về cạnh nhưng ứng với việc chọn C trước A, trái thứ tự chữ cái. Phương án "B, A, C, D, B" dùng cạnh A–C không tồn tại. Phương án "B, C, D, A, B" dùng cạnh D–A không tồn tại và bỏ sót một cạnh B–A.

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ộ đề