Apr 5, 2009

Trees

8.1 Introduction-
A binary tree is either empty or it consists of a node called the root together with two binary trees called the Left subtree and the right subtree of the root.

8.2 Operations on Binary trees.
1. Insertion in Binary Tree
2. Deletion in Binary Tree
3. Traversal of Trees
a. Pre-order Traversal ( Root-Left-Right )
b. In-order Traversal ( Left-Root-Right )
c. Post-order Traversal ( Left-Right-Root )

Applications

1. Comparison Trees
2. Expression Trees


Experiment 24

Aim –Write a program to create a binary tree

Algorithm -

Let create_tree (info,node) be a procedure where info is the information for which we have to create node and node is a structure type variable with pointers to point to both left and right child.

1. [check whether the tree is empty]
If node = NULL
Node=create a node
Left[node]=NULL
Right[node]=NULL
2. [Test for the left child]
If info[node] >= info
Left[node]=Call create_tree(info,left[node])
else
Right[node]=Call create_tree(info,right[node])
3. return (Node)

8.3 Viva Voice

1. What is a Tree
2. Define the following terms
a. Degree
b. Depth
c. Path
d. Forest
3. Differentiate between Terminal nodes and non-terminal nodes
4. What is Binary tree.
5. Mention the properties of binary tree
6. What is Strictly & completely binary Tree
7. How binary tree is represented in computers memory?
8. What is thearded binary tree? It’s advantages and disadvantages
9. Draw the binary tree using the given traversals?
10. What is AVL tree?
11. Whait if forest?

No comments:

Post a Comment