530 Minimum Absolute Difference in BST
Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes.
Example:
Note:There are at least two nodes in this BST.
Complexity: O(n) time O(N) space
The Idea: If we run an in order traversal through the tree, the minimum difference is guaranteed to be between two adjacent elements. So that is what we do while maintaining the minimum value.
Last updated