A perfect binary tree looks like the following. It is a full binary tree, in which all
Question:
A perfect binary tree looks like the following. It is a full binary tree, in which all nodes have two children except the leaf nodes, and all leaf nodes are at the same level.
The module allows the building and manipulation of different types of binary trees. Use the module to write a complete Python program containing the parts in the same order as the questions.
(i) Use 7 carefully chosen integers to build a perfect binary search tree with height of 2(the above example has height of 3). You should use the Node class of the binarytree module. Then print the tree.
(ii) The binarytree module offers a way to build perfect binary tree using the bst function (https://www.geeksforgeeks.org/binarytree-module-in-python/). Use the function to build a perfect binary search tree with height of 3. Then print the tree.
(iii) For the tree built in part (ii) above,o Print the total number of nodeso Print the total number of leaveso Print the left most node in the tree. Hint: use in-order traversal.o Print the right most node in the tree. Hint: use in-order traversal.
Computer Networking A Top-Down Approach
ISBN: 978-0136079675
5th edition
Authors: James F. Kurose, Keith W. Ross