You are on page 1of 8

Fill in the Blanks on Unit III Trees

1. In a binary tree, each node has _maximum of 2 children____________


2. Nodes with no children are called leaves, or external nodes
3. Nodes which are not leaves are called internal nodes (branch node).
4. Nodes with the same parent are called siblings.
5. Maximum height of an empty tree is 0.
6. If a binary tree has only one node, its depth is 1.
7. if the root node has both left subtree and right subtree then depth will be greater values among
depth of the left and right subtrees plus 1
8. A binary tree is said to be balanced If the depth difference between a left subtree and right
subtree of any node in a binary tree is not greater than 1, it is balanced.
9. The number of subtrees of a node is called the degree of the node.
10. In a binary tree, all nodes have degree 0, 1, or 2.
11. A node of degree zero is called a terminal node or leaf node.
12. The degree of a tree is the maximum degree of a node in the tree.
13. the level of the root is zero; and the level of any other node is one higher than that of its parent
14. If every non-leaf node in a binary tree has nonempty left and right subtrees, the tree is termed a
strictly binary tree.
15. All of the nodes in a strictly binary tree are of degree zero or two, never degree one.
16. A strictly binary tree with N leaves always contains 2N – 1 nodes.
17. A full binary tree with n leaves contains 2n –1 nodes.
18. The number of leaf nodes in a complete binary tree of depth d is 2(d-1)
19.
20. The depth of a complete binary tree is given by ___D n = log2n+1______.
21. When converting binary tree into extended binary tree, all the original nodes in binary tree are
internal nodes on extended tree_____________.
22. A full binary tree with 2n+1 nodes contain__n non-leaf nodes____________.
23. A binary tree in which if all its levels except possibly the last, have the maximum number of
nodes and all the nodes at the last level appear as far left as possible, is known as complete
binary tree.
24. Two sibling in a tree have_same father same ascendants________
25. A binary tree of depth “d” is an almost complete binary tree if
i. Each leaf in the tree is either at level “d” or at level “d–1”
ii. For any node “n” in the tree with a right descendent at level “d” all the left descendents
of “n” that are leaves, are also at level “d”
26. Distance from a node A to node B can be calculated if_A is ascendant of B__
27. The time required in best case for search operation in binary tree is O(log n)
28. the total number of nodes in the complete binary tree of depth 4 is 31.
Formula : 2(d+1) -1
29. A Binary tree with N internal nodes has 2N links, N-1 links to internal nodes and N+1 links to
external nodes.
30. If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will
have? Ans: 57 Formula(N+1)
31. A binary tree with 45 internal nodes has _____ 46____ links to external nodes. Formula (N+1)
32. If there are N external nodes is a binary tree then what will be the no. of the internal nodes in
this binary tree? Ans: N-1
33. In Complete binary tree the bottom level is filled from __ Left to right_____.
34. If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT a _
Complete Binary tree_______. 
35. We implement the heap by _ Complete binary tree___________ .
36. It is necessary for Huffman encoding tree to be, Binary tree
37. A tree is a __________
i. hierarchical structure
ii. a graph without a cycle
iii. it is directed graph with a unique node known as root
38. Degree of a node in a tree is_______ number of children
39. Height of the tree is________
i. height of the root node
ii. distance of the root node from the farthest node
40. A binary tree is obtained from a general tree by__ leftmost child right sibling relation______
41. Maximum number of nodes in a binary tree of height h is _________ (2^(h+1)) -1
42. Maximum number of nodes in complete (full) a binary tree of height h is ___ (2^(h+1)) -1_____
43. A complete (full) binary tree of level 5 has "how many nodes"? Ans :63 {Formula : 2 (level+1) – 1}
44. A binary tree having n nodes and depth d will be almost complete binary tree if__ for any node x
in the tree,with right descendant at level d, x must have a left son_____
45. A tree with n nodes have __ n-1_____ edges
46. What is the output of the following code in context of a binary tree:
int f(node *T)
{
int i;
if(T = = NULL)
return (0);
if(T->left = = NULL && T->right = = NULL)
return 1;
if (f(T->left) +f(T->right));
return (i);
}
Ans: number of leaf nodes
47. The height of a binary tree with root node T is given by ________ 1 + maximum(height of left
subtree of T,height of right subtree of T)
48. What is the output of the follwing code in context of a binary tree?
node *f(node *T)
{
node *p;
p = NULL;
if( T != NULL)
{
p = new node;
p->data = T->data;
p->left = f(T->left);
p->right = f(T->right);
}

return (p);
}
Ans: copy of T
49. If there are 16 leaf nodes in a complete (full) binary tree than the total number of nodes in the
tree are_____ 31__
50. A full binary tree with n non-leaf nodes contains__ n+1_____ leaf nodes.
51. What is the output of following code ? code is written for a binary tree.
int f(node *T)
{
int i;
if(T = = NULL)
return (0);
if(T->left = = NULL && T->right = = NULL)
return (0);
if (T->left = = NULL || T->right = = NULL)
return (f(T->left) + f( T->right));
return (1+ f((T->left) + f( T->right));
}
Ans: Counts number of nodes of degree 2
52. Depth of complete binary tree with n nodes is ____ O(logn)______.
53. The correct declaration of a node in a tree is__________
Ans: struct node
{
int data;
node *left;
node *right;
};
54. int f(node *T1,node *T2)
{
int i=0;
if(T1 = = NULL && T2 = = NULL)
i=1;
else if(T1->data = = T2->data)
{
i = f (T1->left , T2->left);
If(i)
i = f( T1->right), T2->right);
}
return i;
}

The above function is for___checking whether two trees are equal or not________.

55. Which of the expression indicates that the t represent an empty tree? Ans: (t = = NULL)
56. What are total number of leaf nodes in a complete binary tree with depth 3? Ans: 8 {Formula:
no. of leaf nodes = 2 d }
57. Consider the following code
int f(node *T, int cnt)
{
static int i=0;
if(T != NULL)
{
if(T->left = = NULL && T->right = = NULL)
{
cout<<T->data;
i++;
return i;
}
else
{
f (T->left ,i)
f( T->right,i);
}
}
}
It returns – Ans: Total number of leaf nodes
58. To represent hierarchical relationship between elements, which data structure is suitable : Tree
59. A binary tree whose every node has either zero or two children is called __extended binary
tree_____.

60. If a node having two children is deleted from a binary tree, it is replaced by its Inorder successor
61. The pre-order and post order traversal of a Binary Tree generates the same output. The tree can
have maximum One node
62. How many nodes in a tree have no ancestors? Ans: 1
63. A binary tree in which every non-leaf node has non-empty left and right subtrees is called a
strictly binary tree. Such a tree with 10 leaves has exactly 19 nodes { Formula : total no. of
nodes in a strictly binary tree =2N-1}
64. The number of possible binary trees with 3 nodes is 5. {refer formula from notes}
65. A tree can have 2 roots :FALSE
66. State true or false.
i) An empty tree is also a binary tree. : True
ii) In strictly binary tree, the outdegree of every node is either o or 2.: True
67. In which of the following tree, parent nodes has key greater than or equal to its both children?
Max heap
68. The children of a node in a tree are called as Siblings.
69. Each element present in a binary tree is called a__node____of that tree
70. The element that represents the base node of the tree is called the_root___of the tree
71. The no of nodes connected to a particular node of tree is called the _Degree___ of that tree
72. The maximum level of any leaf node in a tree is called the __Depth___ of the binary tree
73. when we traverse from root to leaf the operation is known as? Ans: Descending
Array Representation
74. if n is the number given to the node then left child occurs at position __2n+1_________
75. if n is the number given to the node then right child occurs at position ___2n+2________
76. which one of the following form of expression is obtained when the expression tree is traversed
in pre-order? Prefix
77. which one of the following form of expression is obtained when the expression tree is traversed
in post-order? Postfix
78. which of the following option is correct for the statement given below
i)The nodes to the original tree are called as internal nodes
ii) The new nodes that are added to the binary tree ,to make it an extended binary tree are
called external nodes.
Ans: both I and II are correct
79. which of the following option is correct for the statement given below
i)if the tree has n nodes then the no of branches it has is(n-1)
ii)except the root node every node in a tree has exactly two parents.
iii)any two nodes of a tree are connected by only one single path.
Ans:only I and III are correct
80. which of the following option is correct for the statement given below
i)for a binary tree of height h the maximum number of nodes can be 2 h+1-1.
ii)any binary tree with n internal node has (n-1) external nodes. {correct is n+1 external nodes}
Ans: only I is correct
81. which of the following is correct sequence of operation that should be performed to traverse a
non-empty binary tree in in-order traversal?
Ans: traverse the left sub-tree in in-order.
Visit the root.
Traverse the right sub-tree in in-order.
82. which of the following is the correct sequence of operation that should be performed to
traverse a non-empty binary tree in pre-order traversal?
Ans: visit the root .
traverse the left sub-tree in pre-order.
traverse the right sub tree in pre-order.
83. which of the following is the correct sequence of operation that should be performed to
traverse a non-empty binary tree in post-order traversal?
Ans: traverse the left sub-tree in post-order.
traverse the right sub tree in post-order.
Visit the root.
84. which of the following statement is correct?

i)if the value of balfact of any node is -1,then the height of the right sub tree of that node is one
more than the height of its left sub tree.
ii)if the value of balfact of any node is 0 then the height of its left and right sub-tree is exactly
the same.
iii)if the value of balfact of any node is 1 then the height of the left sub tree of that node is one
more than the height of its right sub tree.

Ans: All are correct

85. Which of the following statement is correct?


Ans: A Threaded Binary Tree is a binary tree in which every node that does not have a right child
has a THREAD (in actual sense, a link) to its INORDER successor.
86. By using _ Threaded binary tree_we avoid the recursive method of traversing a Tree, which
makes use of stacks and consumes a lot of memory and time.
87. In a threaded binary tree which nodes have NULL child pointers, All leaf nodes
88. An expression tree will always be a, Binary search tree
89. In threaded binary tree, the NULL pointers are replaced by the Inorder successor or predecessor
90. If there are N external nodes is a binary tree then what will be the no. of the internal nodes in
this binary tree? Ans: N-1
91. A Threaded Binary Tree is a binary tree in which every node that does not have a right child has
a THREAD (in actual sense, a Link) __ Inorder_________Successor.
92. Which of the following traversal techniques lists the nodes of a binary search tree in ascending
order ? Ans: Inorder
93. In order to get the information stored in a Binary Search Tree in the descending order, one
should traverse it in which of the following order? Ans: right, root, left {Inorder gives ascending
order so reverse the sequence of inorder to get descending order}
94. If a node having two children is deleted from a binary tree, it is replaced by its Inorder successor
95. The inorder traversal of tree will yield a sorted listing of elements of tree in _ binary search
trees.________.
96. If root node is stored at index i, its left, and right children are stored at indices 2*i+1, 2*i+2 respectively
97. In a binary tree, certain null entries are replaced by special pointers which point to nodes higher
in the tree for efficiency. These special pointers are called __thread_____.
98. If each node in tree has value greater than every value in its left subtree & has value less than
every value in right subtree then that tree is called as -----Binary search tree
99. The time complexity of searching an element from BST is----O(logn)
100. One can make exact replica of BST by traversing it in---Preorder
101. If there are N nodes then how many NULL pointers are there in Tree: N+1
102. Threads are pointed in -upward—direction

103. Preorder Traversal: GBQACKFPDERH


Inorder Traversal:QBKCFAGPEDHR
Find Postorder Traversal.
Ans: QKFCABEHRDPG
104. Preorder Traversal:ABDEFGCHIJKL
Inorder Traversal:DFEGBCAIHKJL
Find Postorder Traversal.
Ans: DFGECBIKLJHA
105. The inorder traversal of tree will yield a sorted listing of elements of tree in
___BST______.
106. The post order traversal of a binary tree is DEBFCA. Find out the pre order traversal.
Ans: ABDECF {Attempt ans. Cant draw binary tree with one only one order}

107. When in-order traversing a tree resulted E A C K F H D B G; the pre-order traversal


would return _____FAEKCDHGB_________. {Attempt Que. Cant draw binary tree with one only
one order}

108. A node that does not have any son is called Leaf node
109. The root node of a tree has level 0
110. which of the following is the correct structure that represents a node of a threaded
binary tree?
struct node
{
enum boolean left;
struct node *leftchild;
int data;
struct node *rightchild;
enum boolean right;
};
111. which of the following would be the correct structure that represents a node of the
general tree?

struct node
{
int data;
struct node *firstchild;
struct node*siblings;
};
112. Let T be a BST with 14 nodes & 60 as external path length. Then the internal path length
is--- 32 {Formula: E=I+2n}
113. Let T be a BST with 10 nodes & 30 as exeternal path length. Then the internal path
length is---10 {Formula: E=I+2n}

114. A BST is created by inserting following integers 50, 14, 65, 5, 20, 57, 91, 3, 8, 37, 60, 25
The number of nodes in Left & Right subtrees are 7,4
115. The numbers 1,2,3,4,5,6,7,8,9,10 will be inserted in BST, In resuting tree , the right
subtree of root contains 3 nodes. The root node will be 7
116. Construct BST for elements 5,3,7,2,4,8. The average number of comparisons required for
successful search in BST with these nodes is—2.33 {Formula: log 2(n)}
117. Construct BST for 10,8,15,12,13,7,9,17,20,18,4,5. What will be the parent node of node :
17 Ans:15
118. The preorder sequence of BST is 30,22,17,27,24,38,34,48. What is the postorder
sequence of the same tree Ans: 17,24,27,22,34,48,38,30
The preorder sequence of BST is 30,22,17,27,24,38,34,48. What is the Inorder sequence of the same tree
Ans: 17,22,24,27,30,34,38,48 { Formula: Sort the sequence to get inorder}

119. The postorder sequence of BST is 10,9,23,21,28,25,15,50,95,60,40,29. What is the


Inorder sequence of the same tree Ans: 9,10,15,21,23,25,28,29,40,50,60,95
120. In which order the numbers 7,5,1,8,3,2 should be inserted into empty BST to get inorder
& preorder sequence as same Ans: 1,2,3,5,7,8
121. The following numbers are inserted into empty BST in given order 10,2,3,5,15,12,18 .
What is the height of BST Ans: 3
122. The numbers 1,2,3,4,5,6,7,8,9,10 will be inserted in BST, In resuting tree ,What is the
height of BST Ans: 9
123. How many distict BST can be created for 4 distict keys Ans: 14
124. A BST is generated by inserting following sequence 50,12,62,5,20,3,8 . The inorder
traversal will be 3,5,8,12,20,50,62
125. To get a complete copy of a given binary tree postorder traversal is required.
126. In a extended-binary tree nodes with 2 children are called ..internal nodes......
127. TREE[1]=NULL indicates tree is ..empty......
128. Sequential representation of binary tree uses .. Array with pointers......
129. In a Threaded binary tree, the NULL pointers are replaced by the in-order successor
or predecessor
130. A threaded binary tree is created by inserting the elements in the following order
9,7,4,11,5,6,10,8,13 now the left of 5 points to 4 {Solved in solution set}
131. In the aove TBT height of 6 is 4 {if root counted as 0}
132. In a threaded binary tree the pointer which will point to the root node will be * Left
most pointer in the left sub-tree of the tree
133. Which of the following statement is true about dummy node of a Threaded binary
tree left pointer of dummy node points to the root and right pointer points to itself

You might also like