Assignment 4
1. Define and determine the following terms in the following figure:
B C
D G
H I
J
a) Vertex
b) Internal and External node
c) Degree of a tree
d) Path of a tree (for all vertices)
e) Forest
2. Illustrate the heap sort algorithm on the following array
38, 81, 22, 48, 13, 69, 93, 14, 45, 58, 79, 72
3. Consider a binary tree rooted at index 3 represented through following array
a. Draw the binary tree
b. Give the sequential representation of the binary tree
c. Give the inorder, preorder and postorder traversals of the binary tree
4. Prove that:
i) Maximum vertices in a binary tree of height h is 2h+1 − 1.
ii) If a strictly binary tree has n1 leaf nodes and n2 nodes of degree 2, then n1=n2+1
iii) An Extended binary tree is strictly binary.
5. Give a representation of a two-way pre-threaded binary tree corresponding to the binary tree
of Q.2. Give its advantage over binary tree.
6. Draw all possible binary trees with:
a. 3 nodes
b. 2-tree with 4 external nodes
7. Draw tree with expression: (2x+y) (5a-b)3.
8. Construct a tree with following traversal:
a. Inorder : cbdafe
b. Postorder : cdbfea
9. Write a C function to insert elements in a BST.
10. What are the cases involved in deleting a key from a BST and how are they handled?
Show the result of deleting the key 9 from the following BST.
11. Write the characteristics of B-Tree. Construct a B-tree on following sequence of inputs
10,20,30,40,50,60,70,80,90.
Assume that the order of the B tree is 3.
12. Describe the method to delete an item from B tree.
13. Draw an AVL tree on following inputs, assume that tree is initially empty:
45, 55, 65, 75, 80, 90, 100, 110, 120, 130, 40, 35, 25, 20, 15,10, 5.
14. Delete the key 10 from the following AVL tree. Show proper rotation to maintain the tree
as AVL.
15. In a message, the frequency of various symbols is as follows
Symbol Frequency
A 24
B 12
C 10
D 8
E 8
a) In a fixed length code, what will be the length of the message?
b) What will be the reduction in the length of the message if Huffman Algorithm is used to
generate variable length code?
16. Describe properties of various types of trees and write algorithms for their operations.