Ch10 PP BinaryTrees
Ch10 PP BinaryTrees
1. Create a 2-tree to store the algebraic expression “2 + 3”. Then perform a preorder,
inorder, and postorder traversal of the tree.
2. Create a 2-tree to store the algebraic expression “(2+3)×6”. Then perform a preorder,
inorder, and postorder traversal of the tree.
3. Construct a binary search tree if items are inserted into an empty tree in the order:
G, M, C, J, D, A, K, E
4. Construct a binary search tree if items are inserted into an empty tree in the order:
1
6. (10.6) Consider the algebraic expression (2x + y)(5a − b)3 .
(a) Draw the corresponding 2-tree.
(b) Use T to write E in Polish prefix form.
9. (10.10) Suppose the following list of letters is inserted into an empty binary search tree:
J, R, D, G, W, E, M, H, P, A, F, Q
(a) Find the final tree T .
(b) Find the inorder traversal of T .
10. (10.11) Consider the binary tree T shown in Figure 2. Describe the tree after:
(a) node M is deleted
(b) node D is deleted
2
11. (10.13, 10.14) There are six symbols in a binary tree T and the weight and code for
each symbol is defined below:
(a) Draw the binary tree T and find the weighted path length P of the tree T .
(b) The encoding does not represent a minimum path length. Use Huffman’s algorithm
to generate a tree with a minimum path length and find the minimum path length
P.
12. (10.23) Find the final tree T if the following numbers are inserted into an empty binary
search tree T :
3
14. (10.26) Let T be the binary search tree shown in the figure above. Suppose nodes
20, 55, 88 are added one after the other to T . Find the final tree T .
15. (10.27) Let T be the binary search tree shown in the figure below. Suppose nodes
22, 25, 75 are deleted one after the other from T . Find the final tree T .
4
16. Decode the string 101100010110111001100111010001001101111010001011 for the tree
shown in Figure 5. The symbol labeled as “sp” is the space character.
17. Create a binary tree using Huffmans encoding algorithm to encode the string including
the space character:
18. Create a binary tree using Huffmans encoding algorithm to encode the string including
the space character: