Question: Your task is to implement the following function in bst.c : int bstClosest( struct node *t, int val); This function should return the value

Your task is to implement the following function in bst.c:

int bstClosest(struct node *t, int val);

This function should return the value in the BST which is closest to the given value. The function can assume the given BST is not empty. If there is more than one closest value, the function may return any of them. For example, consider the following BST:

static struct node *newNode(int val);

static void showBstNode(struct node *t);

static void doBstPrint(struct node *t, FILE *out);

int bstClosest(struct node *t, int val) {

// TODO: Task 4 - Implement this function

return -1;

}

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 Programming Questions!