Binary search tree is given. Return the pointer to the minimum element.
Definition of a tree:
class TreeNode {
public int val;
public TreeNode left;
public TreeNode right;
TreeNode(int x) {
val = x;
left = null;
right = null;
}
}class TreeNode {
public:
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};Implement function Minimum that returns pointer to the element with minimum value in the tree.
TreeNode Minimum(TreeNode tree)TreeNode* Minimum(TreeNode *tree)
Function Minimum returns pointer to the node with value 2 - the vertex with minimum value in the tree.