All pastes #77516 Raw Edit

Unnamed

public java v1 · immutable
·published 2006-07-03 03:21 UTC
rendered paste body
    private TreeNode buildSub ( TreeNode p )  throws IOException    // Recursive partner of the build() method. Builds a subtree and    // sets p to point to its root.    {	  		if(root == null){  	  			root = p;  	  		}   	  char elem = (char)System.in.read( );  	  ExprTreeNode input = new ExprTreeNode(elem,null,null);  	   	  if((elem == '*' ||elem == '/' ||elem == '+' ||elem == '-')){   	  		p.setLeft(input);  	  		buildSub(p);  	  		p.setRight(input);  	  		return input;    	}    	else if(elem >= '0' && elem <='9'){     			p.setLeft(input);    			buildSub(p);           	  	p.setRight(input);          	  	return input;     		}  	return null;    }