Unit 4
Unit 4
Unit 4
2MARKS
1. Define tree?
Trees are non-liner data structure, which is used to store data items in a shorted sequence.
It represents any hierarchical relationship between any data Item. It is a collection of
nodes, which has a distinguish node called the root and zero or more non-empty sub trees
T1, T2,….Tk. each of which are connected by a directed edge from the root.
The height of n is the length of the longest path from root to a leaf. Thus all leaves have
height zero. The height of a tree is equal to a height of a root.
For any node n, the depth of n is the length of the unique path from the root to node n.
Thus for a root the depth is always zero.
5. Define sibling?
Nodes with the same parent are called siblings. The nodes with common parents are
called siblings.
A Binary tree is a finite set of data items which is either empty or consists of a single
item called root and two disjoin binary trees called left sub tree max degree of any node is
two.
a. Linear representation.
b. Linked representation
Ø Syntax analysis
Expression tree is also a binary tree in which the leafs terminal nodes or operands and
non-terminal intermediate nodes are operators used for traversal.
1. Inorder traversal
2. Preoder traversal
3. Postorder traversal.
A binary tree is threaded by making all right child pointers that would normally be null
point to the in order successor of the node, and all left child pointers that would normally be null
point to the in order predecessor of the node.
14. What are the types of threaded binary tree?
Binary search tree is a binary tree in which for every node X in the tree, the values of all the keys
in its left subtree are smaller than the key value in X and the values of all the keys in its right
subtree are larger than the key value in X.
AVL stands for Adelson-Velskii and Landis. An AVL tree is a binary search tree which has the
following properties:
17. List out the steps involved in deleting a node from a binary search tree.
A B-tree is a tree data structure that keeps data sorted and allows searches, insertions, and
deletions in logarithmic amortized time. Unlike self-balancing binary search trees, it is optimized
for systems that read and write large blocks of data. It is most commonly used in database and
file systems.
If all its levels, possible except the last, have maximum number of nodes and if all the nodes in
the last level appear as far left as possible
16 MARKS
1. Explain the AVL tree insertion and deletion with suitable example.
2. Describe the algorithms used to perform single and double rotation on AVL
tree.
3.Write short notes on
i. Binomial heaps
ii. Fibonacci heaps
4.Explain the tree traversal techniques with an example.
5.Construct an expression tree for the expression (a+b*c) + ((d*e+f)*g). Give the outputs
when you apply inorder, preorder and postorder traversals.
6. How to insert and delete an element into a binary search tree and write down the code for
the insertion routine with an example.
7. What are threaded binary tree? Write an algorithm for inserting a node in a threaded
binary tree.
8. Create a binary search tree for the following numbers start from an empty binary search
tree. 45,26,10,60,70,30,40 Delete keys 10,60 and 45 one after the other and show the trees at
each stage.