ProAnswers.org

algorithm Element with minimum value in a Binary Search Tree

algorithm Element with minimum value in a Binary Search Tree

typedef struct node{

	    int data;

	    struct node *left, *right;

	}node;

	 

	/*Returns node with maximum key value */

	node *tree_max(node *root){

	    while(root -> right != NULL){

	        root = root -> right;

	    }

	    return root;

	}

	 

	/*Returns node with minimum key value*/

	node *tree_min(node *root){

	    while(root -> left != NULL){

	        root = root -> left;

	    }

	        return root;

	}