Question: Binary Search Tree (14 points) Recall that in a binary search tree, each node is defined as follows. struct node { int key; node


Binary Search Tree (14 points) Recall that in a binary search tree, each node is defined as follows. struct node { int key; node *left; node *right; node *parent; \ Other data *\ } Recall that in a binary search tree, at every node, the key at a node is larger than or equal to the keys in its left subtree, and is smaller or equal to the keys its right subtree. In each case below, write a procedure in a C-like language that achieves the required task. (a) (3 pt) Compute the sum of all the keys in the binary tree. int Sum (node* root) { (b) (3 pt) Given a (d) (4 pt) Given integers a and b, perform a linear transformation au bon all keys in the tree, i.e., if a node has key value v originally, the new key value should be au ib. The new tree must also be a binary search tree. The method should return the pointer to the root of the new tree. node Transform (node* root, int a, int b) {
Step by Step Solution
3.31 Rating (157 Votes )
There are 3 Steps involved in it
Let us see the procedures in a Clike language a Compute the sum of all keys in the binary tree int S... View full answer
Get step-by-step solutions from verified subject matter experts
