Subversion Repositories programming

Rev

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

Rev 30 Rev 31
Line 112... Line 112...
112
        return answer;
112
        return answer;
113
    }
113
    }
114
    
114
    
115
    //misc methods ----------------------------------------------------------
115
    //misc methods ----------------------------------------------------------
116
    public boolean isLeaf() { 
116
    public boolean isLeaf() { 
117
        if( left == right == null ) { return true; }
117
        if( (left == null) && (right == null) ) { return true; }
118
        return false;
118
        return false;
119
    }
119
    }
-
 
120
    
120
    public int size() { }
121
    public int size() { 
-
 
122
        int answer=1; // 1 for the node we are at
-
 
123
        if( !(left == null) ) { answer += left.size(); }
-
 
124
        if( !(right == null) ) { answer += right.size(); }
-
 
125
 
-
 
126
        return answer;
-
 
127
    }
-
 
128
    
121
    public int height() { }
129
    public int height() {
-
 
130
        if( this.isLeaf() ) { return 0; }
-
 
131
        int l=1,r=1;
-
 
132
        l += left.height();
-
 
133
        r += right.height();
-
 
134
 
-
 
135
        return Math.max(l,r);
-
 
136
    }
-
 
137
    /*
122
    public boolean contains( Object object ) { }
138
    public boolean contains( Object object ) { }
123
    public int numLeaves() { }
139
    public int numLeaves() { }
124
    public int count( Object x ) { }
140
    public int count( Object x ) { }
125
    public boolean isFull() { }
141
    public boolean isFull() { }
126
    public boolean isBalanced() { }
142
    public boolean isBalanced() { }