Which one of the following is the correct formulae to find the parent node at index I?

Category: QuestionsWhich one of the following is the correct formulae to find the parent node at index I?
Editor">Editor Staff asked 1 month ago

Which one of the following is the correct formulae to find the parent node at index I?
 
(a) (I-1)/K
 
(b) (I+1)/K
 
(c) (I*1)/K
 
(d) (I-2)/K
 
The question is from K-ary Tree in division Trees of Data Structures & Algorithms I
 
I got this question in a national level competition.

1 Answers
Editor">Editor Staff answered 1 month ago

The correct option is (a) (I-1)/K
 
To explain: The parent node for the node of index I in a K-ary tree is given by (I-1)/K.