Question: Implement the member function int countless Than/T & val, TNode * node), which returns the number of values in the tree that are less than

 Implement the member function int countless Than/T & val, TNode* node),

Implement the member function int countless Than/T & val, TNode* node), which returns the number of values in the tree that are less than val. Examples. In the illustration above: countlessThan(10, root) should return 6. countless Than(9. root) should return 5. countless Than(20, root) should return 8. countlessThan(4. root) should return 2. countless Than(2, root) should return O. Complete the following code to perform this task (assume that the BST has no duplicates and that val is not necessarily in the tree) 1 template 2 int BST:: countlessThan(T& val, TNode * node) { if (node == nullptr) return B 3 4 5 6 7 8 9 10 11 if (val -- node->val) return else if (val val) return else if (val > node->val) return E 13 Hint: Remember that each node stores the size of the subtree rooted at that node

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