1.

What may be the psuedo code for finding the size of a tree?(a) find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node)(b) find_size(root_node–>left_node) + find_size(root_node–>right_node)(c) find_size(root_node–>right_node) – 1(d) find_size(root_node–>left_node + 1The above asked question is from Binary Trees using Linked Lists in chapter Binary Trees of Data Structures & Algorithms IThis question was posed to me in a job interview.

Answer» CORRECT choice is (a) find_size(root_node–>left_node) + 1 + find_size(root_node–>right_node)

Easy explanation - Draw a tree and analyze the expression. we are always taking size of left subtree and right subtree and adding root VALUE(1) to it and FINALLY PRINTING size.


Discussion

No Comment Found

Related InterviewSolutions