Subversion Repositories programming

Rev

Rev 31 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 31 Rev 32
Line 132... Line 132...
132
        l += left.height();
132
        l += left.height();
133
        r += right.height();
133
        r += right.height();
134
 
134
 
135
        return Math.max(l,r);
135
        return Math.max(l,r);
136
    }
136
    }
-
 
137
    
-
 
138
    public boolean contains( Object object ) { 
-
 
139
        if( root.equals(object) ) { return true; }
-
 
140
        if( this.isLeaf() ) { return false; }
-
 
141
        return left.contains(object) || right.contains(object);
-
 
142
    }
-
 
143
    
-
 
144
    public int numLeaves() { 
-
 
145
        if( this.isLeaf() ) { return 1; }
-
 
146
        return left.numLeaves() + right.numLeaves();
-
 
147
    }
-
 
148
    
-
 
149
    public int count( Object x ) { 
-
 
150
        int answer=0;
-
 
151
        if( root.equals(x) ) { answer=1; }
-
 
152
        if( !(left == null) ) { answer += left.count(x); }
-
 
153
        if( !(right == null) ) { answer += right.count(x); }
-
 
154
        return answer;
-
 
155
    }
137
    /*
156
    /*
138
    public boolean contains( Object object ) { }
-
 
139
    public int numLeaves() { }
-
 
140
    public int count( Object x ) { }
-
 
141
    public boolean isFull() { }
157
    public boolean isFull() { }
142
    public boolean isBalanced() { }
158
    public boolean isBalanced() { }
143
    public int pathLength() { }
159
    public int pathLength() { }
144
    public BinaryTree reverse() { }
160
    public BinaryTree reverse() { }
145
    public int level( Object x ) { }
161
    public int level( Object x ) { }