Question: Which of the following functions returns the second smallest node in a binary search tree r ? find _ smallest ( tree _ node *

Which of the following functions returns the second smallest node in a binary search tree r? find_smallest(tree_node* r) function returns the node with smallest value in a tree r. If tree r is empty find_smallest returns NULL.
tree_node* find_second_smallest(tree_node* r){
if (r->left==NULL) return find_smallest(r->right);
tree_node *p = find_second_smallest(r->left);
if (p==NULL) return r;
else return p;
}
tree_node* find_second_smallest(tree_node* r){
if (r->left==NULL) return find_smallest(r->right);
return find_second_smallest(r->left);
}
tree_node* find_second_smallest(tree_node* r){
if (r->left==NULL) return find_smallest(r->right);
tree_node *p = find_second_smallest(r->left);
if (p!=NULL) return r;
else return p;
}
tree_node* find_second_smallest(tree_node* r){
tree_node *p = find_second_smallest(r->left);
if (p!=NULL) return r;
else return p;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!