Given a Binary Search Tree, the task is to find the node with the maximum value in a BST.
For the above tree, we start with 20, then we move right 22, we keep on moving to right until we see NULL. Since right of 22 is NULL, 22 is the node with maximum value.
Approach: This is quite simple. Just traverse the node from root to right recursively until right is NULL. The node whose right is NULL is the node with maximum value.
Maximum 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.
- Find the node with maximum value in a Binary Search Tree using recursion
- Complexity of different operations in Binary tree, Binary Search Tree and AVL 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
- Binary Tree to Binary Search Tree Conversion
- Minimum swap required to convert binary tree to binary search tree
- Binary Tree to Binary Search Tree Conversion using STL set
- Difference between Binary Tree and Binary Search Tree
- Binary Search Tree | Set 1 (Search and Insertion)
- Meta Binary Search | One-Sided Binary Search
- Find maximum count of duplicate nodes in a Binary Search Tree
- Insert a node in Binary Search Tree Iteratively
- Search a node in Binary Tree
- Postorder predecessor of a Node in Binary Search Tree
- Maximum sub-tree sum in a Binary Tree such that the sub-tree is also a BST
- Convert a Binary Search Tree into a Skewed tree in increasing or decreasing order
- Count the Number of Binary Search Trees present in a Binary Tree
- Sum and Product of minimum and maximum element of Binary Search Tree
- Maximum height of the binary search tree created from the given array
- Queries to find the maximum Xor value between X and the nodes of a given level of a perfect binary tree
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.