# C++ Program to Find the Minimum value of Binary Search Tree

C++Server Side ProgrammingProgramming

It is a program to find the minimum value of a binary search tree.

## Algorithms

Begin
Declare nd as a structure.
Declare d to the integer datatype.
Declare pointer lt to the structure nd type.
Declare pointer lt to the structure nd type.
Declare function new_nd() to the structure nd type.
Declare d to the integer datatype.
Pass them as a parameter.
Declare pointer nd to the structure nd type.
Initialize nd = (struct nd*) malloc(sizeof(struct nd)).
nd->d = d.
nd->lt = NULL.
nd->rt = NULL.
return(nd).
End
Begin
Declare function add_node() to the structure nd type.
Declare pointer nd to the structure nd type.
Declare d to the integer datatype.
Pass them as a parameter.
if (nd == NULL) then
return(new_nd(d)).
else
if (d <= nd->d) then
else
return nd.
End
Begin
Declare minimum_val() function to the integer datatype.
Declare pointer nd to the structure nd type.
Pass it as a parameter.
Declare pointer cur to the structure nd type.
Initialize cur = nd.
while (cur->lt != NULL) do
cur = cur->lt.
return(cur->d).
Declare pointer root to the structure nd type.
Initialize root = NULL.
Print "The Minimum value of the given binary search tree is: ".
Print the minimum value of binary tree.
getchar().
End.

## Example

Live Demo

#include <bits/stdc++.h>
using namespace std;
struct nd {
int d;
struct nd* lt;
struct nd* rt;
};
struct nd* new_nd(int d) {
struct nd* nd = (struct nd*)
malloc(sizeof(struct nd));
nd->d = d;
nd->lt = NULL;
nd->rt = NULL;
return(nd);
}
struct nd* add_node(struct nd* nd, int d) {
if (nd == NULL)
return(new_nd(d));
else {
if (d <= nd->d)
else
return nd;
}
}
int minimum_val(struct nd* nd) {
struct nd* cur = nd;
while (cur->lt != NULL) {
cur = cur->lt;
}
return(cur->d);
}
int main() {
struct nd* root = NULL;
}
The Minimum value of the given binary search tree is: 25