Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 501 Bytes

Minimum element in bst.md

File metadata and controls

36 lines (21 loc) · 501 Bytes

METHOD 1

int minValue(Node* root) {

    if(root==NULL) return -1;
    
    while(root->left!=NULL)
        root=root->left;
        
    return root->data;
}

METHOD 2

 int minValue(Node* root) {
      
        if(root==NULL)
            return -1;
        
        int t = root->data;
        
        if(root->left!=NULL)
             t = minValue(root->left);
            
        return t;
    }