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 C, 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: "C, D, A, C, B, A, C". Đồ thị có các cạnh A–B, A–D, B–C, C–D và hai cạnh song song A–C, mọi đỉnh đều bậc chẵn. Chạy thuật toán từ C: đỉnh kề C đứng đầu theo thứ tự chữ cái là A nên đẩy A và bỏ một cạnh A–C; từ A chọn B, bỏ A–B; từ B chỉ còn C, bỏ B–C; từ C chọn A, bỏ cạnh A–C còn lại; từ A chọn D, bỏ A–D; từ D chọn C, bỏ C–D. Ngăn xếp từ đáy lên là C, A, B, C, A, D, C và mọi đỉnh đã cô lập, nên lần lượt lấy ra ghi vào mảng kết quả theo chiều ngược lại, cho C, D, A, C, B, A, C. "C, A, B, C, A, D, C" là ngăn xếp đọc từ đáy lên, tức cùng chu trình nhưng đi theo chiều ngược, không phải mảng mà thuật toán xuất ra. "C, B, A, C, A, D, C" rời C bằng cạnh C–B, trái với quy tắc chọn đỉnh kề đầu theo thứ tự chữ cái. "C, B, A, D, C, A, C" cũng mở đầu bằng C–B nên vướng đúng chỗ đó dù vẫn đi đủ sáu cạnh. "C, B, A, D, C" chỉ dùng bốn cạnh, bỏ sót hai cạnh nên không phải chu trình Euler.

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