Given a Binary Search Tree. The task is to find the sum and product of maximum and minimum value of tree.
For the above tree, sum and product of maximum and minimum value of tree is 26 and 88 respectively.
- For the node with minimum value: Find the leftmost leaf node
- For the node with maximum value: Find the rightmost leaf node
Below is the implementation of the above approach:
Sum of Maximum value and Minimum value in BST is 7 Product of Maximum value and Minimum value in BST is 6
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Sum and Product of maximum and minimum element in Binary Tree
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Minimum swap required to convert binary tree to binary search tree
- Difference between Binary Tree and Binary Search Tree
- Binary Tree to Binary Search Tree Conversion
- Binary Tree to Binary Search Tree Conversion using STL set
- Binary Search Tree | Set 1 (Search and Insertion)
- Meta Binary Search | One-Sided Binary Search
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Sum and Product of minimum and maximum element of an Array
- Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
- Find the closest element in Binary Search Tree
- Find the closest element in Binary Search Tree | Space Efficient Method
- Kth Smallest element in a Perfect Binary Search Tree
- Find maximum and minimum element in binary tree without using recursion or stack or queue
- Count the Number of Binary Search Trees present in a Binary Tree
- Find the node with minimum value in a Binary Search Tree
- Find the node with minimum value in a Binary Search Tree using recursion
- Find the node with maximum value in a Binary Search Tree
- Find the node with maximum value in a Binary Search Tree using recursion
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.