Binary Tree
Binary Tree
The inorder and preorder traversal of a binary tree are d b e a f c g and a b d e c f g, respectively.
The postorder traversal of the binary tree is:
debfgca
A
edbgfca
B
edbfgca
C
defgbca
D
Which of the following pairs of traversals is not sufficient to build a binary tree from the given
traversals?
Preorder and Inorder
A
Preorder and Postorder
B
Inorder and Postorder
C
None of the Above
D
Which traversal of tree resembles the breadth first search of the graph?
Preorder
A
Inorder
B
Postorder
C
Level order
D
Which of the following tree traversal uses a queue data structure?
Preorder
A
Inorder
B
Postorder
C
Level order
D
Consider the following C program segment
struct CellNode
{
struct CelINode *leftchild;
int element;
struct CelINode *rightChild;
}
What is the average case time complexity for finding the height of the binary tree?
a) h = O(loglogn)
b) h = O(nlogn)
c) h = O(n)
d) h = O(log n)
Answer: d
Explanation: The nodes are either a part of left sub tree or the right sub tree, so we don’t have to traverse all the
nodes, this means the complexity is lesser than n, in the average case, assuming the nodes are spread evenly, the
In a full binary tree if number of internal nodes is I, then number of leaves L are?
a) L = 2*I
b) L = I + 1
c) L = I – 1
d) L = 2*I – 1
Answer: b
Explanation: Number of Leaf nodes in full binary tree is equal to 1 + Number of Internal Nodes i.e L = I + 1
In a full binary tree if number of internal nodes is I, then number of nodes N are?
a) N = 2*I
b) N = I + 1
c) N = I – 1
d) N = 2*I + 1
View Answer
Answer: d
Explanation: Relation between number of internal nodes(I) and nodes(N) is N = 2*I+1.
9. In a full binary tree if there are L leaves, then total number of nodes N are?
a) N = 2*L
b) N = L + 1
c) N = L – 1
d) N = 2*L – 1
Answer: d
Explanation: The relation between number of nodes(N) and leaves(L) is N=2*L-1.