find minimum in array java code example

Example: minimum and maximum values in a bst java

int max(Node t) { 
    	        	if(t == null)
    	        		return 0;
    	            while (t.right != null)  
    	                t = t.right; 
    	             System.out.println(t.data); 
    	            return t.data; 
    	        }
    	        //Node max(Node t) {
    	        	 // if (t.right != null) { 
      	               // return min(t.right);
      	            //} 
      	            //return t;
    	        //}
    	        int min(Node t) {
    	        	if(t == null)
    	        		return 0;
    	            while (t.left != null)  
    	                t = t.left; 
    	             System.out.println(t.data); 
    	            return t.data; 
    	        }
    	        //Node min(Node t) { 
    	          //  if (t.left != null) { 
    	            //    return min(t.left);
    	            //} 
    	            //return t; 
    	        //}

Tags:

Java Example