Question: You have been given a recursive function to sum the values of all keys in a BST: int findSum(TreeNode root, int depth) if(root !=NULL) int
You have been given a recursive function to sum the values of all keys in a BST: int findSum(TreeNode root, int depth) if(root !=NULL) int leftSum = findSum(root->left, depth + 1); int rightSum findSum( root->right, depth 1); cout key if (depth!0) cout key; else
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
