Binary tree important questions and answers in “Data structures.” These 2 mark Q & A will be used by Engineering stream and all kind of computer related students.
BINARY TREE
1. Define a binary tree.
A binary tree is a tree which has nodes either empty or not more than two child nodes, each of which may be a leaf node.
2. Define a full binary tree.
A full binary tree is a tree in which all the leaves are on the same level and every non-leaf node has exactly two children.
3. Define a complete binary tree.
A complete binary tree is a tree in which every non-leaf node has exactly two children not necessarily to be on the same level.
4. Define a right-skewed binary tree.
A right-skewed binary tree is a tree, which has only right child nodes.
5.State the properties of a binary tree.
- Maximum No.of nodes on level n of a binary tree is2 (n-1), where n>=1.
- Maximum No.of nodes in a binary tree of height is 2(n-1), where n>=1.
- For any non-empty tree, nl=nd+l, where nl is the number of leaf nodes and nd is the no.of nodes of degree 2.
6.What are the different ways of representing a binary tree?
- Linear representation using arrays.
- Linked representation using pointers.
7.State the merits of linear representation of a tree.
- Store methods are easy and can be easily implemented in arrays.
- When the location of the parent /child node is known, other one can be determined easily.
- It requires static memory allocation, so it is easily implemented in all programming languages
8.State the demerits of linear representation of a tree.
- Insertions and deletions are tougher.
- Processing consumes excess of time.
- Slow data movements up and down the array.
SEE: Engineering Mini Projects free download
9. Define Traversal.
Traversal is an operation which can be performed on a binary tree by visiting all the nodes exactly once.
Inorder : traversing the Left sub-tree(LST) , visiting the root and finally traversing the Right sub tree(RST).
Preorder : visiting root, traversing Left sub-tree(LST) and finally traversing Right sub tree(RST).
Postorder :traversing Left sub-tree(LST), then Right sub tree(RST) and finally visiting root.
10. What are the tasks performed while traversing a binary tree?
- Visiting a node.
- Traverse the left structure.
- Traverse the right structure.
Read: Why Engineering students are JOBLESS in India
11.What are the tasks performed during preorder traversal?
- Process the root node.
- Traverse the left sub-tree.
- Traverse the right sub-tree.
Ex : +AB
12. What are the tasks performed during inorder traversal?
- Traverse the left sub-tree.
- Process the root node.
- Traverse the right sub-tree.
Ex:A+B
- Read: Learn English Quickly
13. What are the tasks performed during postorder traversal?
- Traverse the left sub-tree.
- Traverse the right sub-tree.
- Process the root node.
Ex: AB+.
- [SEE: C Program Tutorials] & [IT Companies Details]
14. Define binary search tree.
A binary search tree is a special binary tree, which is either empty or if it is empty it should satisfy the conditions given below:
- Every node has a value and no two nodes should have the same value.
- The value in any left sub-tree is less than the value of its parent node.
- The value in any right sub-tree is greater than the value of its parent node.