Data Structure Questions and Answers-Binary Trees using Array

Data Structure Questions and Answers-Binary Trees using Array

 Question 1
Binary trees can have how many children?
 A 2 B any number of children C 0 or 1 or 2 D 0 or 1
Question 1 Explanation:
Can have atmost 2 nodes.

 Question 2
Disadvantage of using array representation for binary trees is?
 A difficulty in knowing children nodes of a node B difficult in finding the parent of a node C have to know the maximum number of nodes possible before creation of trees D difficult to implement
Question 2 Explanation:
The array is fixed size (may be dynamic array or static array) but size is fixed.

 Question 3
What must be the ideal size of array if the height of tree is 'l'?
 A 2l-1 B l-1 C l D 2l
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
What are the children for node 'w' of a complete-binary tree in an array representation?
 A 2w and 2w+1 B 2+w and 2-w C w+1/2 and w/2 D w-1/2 and w+1/2