Your task is to implement the following function in bst.c : int bstClosest( struct node *t,
Fantastic news! We've Found the answer you've been seeking!
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 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;
}
Related Book For
Essentials of Business Analytics
ISBN: 978-1285187273
1st edition
Authors: Jeffrey Camm, James Cochran, Michael Fry, Jeffrey Ohlmann, David Anderson, Dennis Sweeney, Thomas Williams
Posted Date: