I am trying to find the smallest value in a max heap(stored in an array) recursively, without reversing the array. I have some problems trying to define the recursive case. How do I give the correct index to the recursive call? (starting index from 1 instead of 0)If the first node is stored in slot i, then I know that its left and right nodes are stored in slot 2*i and 2*i+1 respectively and so are their own left and right nodes. How do I pass this information recursively?
pseudo-code:
smallest(size ,index_of_parent_node){
i = size/2
if (i == 0)
return A[i]
else
return min[smallest(size/2 , index_of_left_of_parent) , smallest(size/2, index_of_right_of_parent)]