YOU CAN DOWNLOAD 200+ SUBJECTS PDF BOOK FOR COMPETITIVE EXAMINATIONS
Data Structure Questions and Answers-Binary Trees using Array
Question 1 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Binary trees can have how many children?
any number of children
0 or 1 or 2
0 or 1
Question 1 Explanation:
Can have atmost 2 nodes.
Question 2 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
Disadvantage of using array representation for binary trees is?
difficulty in knowing children nodes of a node
difficult in finding the parent of a node
have to know the maximum number of nodes possible before creation of trees
difficult to implement
Question 2 Explanation:
The array is fixed size (may be dynamic array or static array) but size is fixed.
Question 3 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What must be the ideal size of array if the height of tree is 'l'?
Question 3 Explanation:
Since maximum elements in a tree (complete binary tree) of height l will be 2l-1 so a good array size must be that (since a binary tree node may not always have 2 children but for safety a is correct).
Question 4 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What are the children for node 'w' of a complete-binary tree in an array representation?
2w and 2w+1
2+w and 2-w
w+1/2 and w/2
w-1/2 and w+1/2
Question 4 Explanation:
Since each node has 2 children and so counting from beginning, a particular node will have children as option a.
Question 5 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the parent for a node 'w' of a complete binary tree in an array representation when w is not 0?
Question 5 Explanation:
Floor of w-1/2 because we can't miss a node.
There are 5 questions to complete.