Given a binary tree below. What is a result of post-order traverse?
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: "7, 4, 5, 3, 8, 6, 2, 1". Post-order đi cây con trái, rồi cây con phải, cuối cùng mới tới gốc. Nhánh trái của gốc 1 là nút 3: xuống 4 thì phải xử lý con trái 7 trước nên ra 7, rồi 4, rồi lá 5, rồi 3, cho 7, 4, 5, 3. Nhánh phải là nút 2: 2 không có con trái, con phải 6 lại có con trái 8, nên ra 8, rồi 6, rồi 2. Gốc 1 in sau cùng. "7, 4, 3, 5, 1, 2, 8, 6" sai vì đó là dãy in-order, trong đó gốc 1 nằm giữa hai nhánh thay vì ở cuối. "1, 3, 4, 7, 5, 2, 6, 8" sai vì đó là dãy pre-order, mở đầu bằng gốc 1 trong khi post-order luôn mở đầu bằng một lá. "1, 3, 4, 7, 5, 2, 8, 6" sai vì nó cũng bắt đầu từ gốc như pre-order, lại còn in 8 trước cha 6 nên không khớp với phép duyệt nào.
Cùng phần 4
What is the minimum number of nodes in a nearly complete binary tree with height 4?
(In a tree the height of root is 1, and a binary tree with height h is called nearly complete if the tree is complete at level d for d = 1, 2, ..., h-1, and the leaves in the last level are all in the leftmost positions).Có lời giảiCâu hỏiTo implement an AVL tree, a concept balance factor is introduced (bal = height(right)-height(left)). Suppose an AVL tree is created by inserting to the tree the following keys sequentially:
6, 3, 7, 2, 5, 1
What is the balance factor of the node 6? (please note that the tree is still AVL)Có lời giảiCâu hỏiSuppose the binary search tree T is made by inserting the following keys consequently: 6, 7, 8, 9, 3, 2, 5, 4
What is the result of breadth-first traverse of T?Có lời giảiCâu hỏiCả 76 câu của chủ đề76 câu
Xuất hiện trong 1 bộ đề
Đi tiếp từ đây