Subversion Repositories programming

Rev

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

Rev 43 Rev 44
Line 221... Line 221...
221
        AVLTree temp = new AVLTree( deleteMinimum(right) );
221
        AVLTree temp = new AVLTree( deleteMinimum(right) );
222
        setThis(temp);
222
        setThis(temp);
223
        
223
        
224
        rebalance(); //fix the balance
224
        rebalance(); //fix the balance
225
        return true;
225
        return true;
-
 
226
    } */
-
 
227
    
-
 
228
    public void ira_dm() {
-
 
229
        System.out.println( this );
-
 
230
        System.out.println( deleteMinimum( this ) );
226
    }
231
    }
227
    
232
    
228
    private int deleteMinimum( AVLTree tree ) {
233
    public AVLTree deleteMinimum( AVLTree tree ) {
229
        int tempKey=0;
234
        if( tree == NIL ) { return NIL; }
230
        
-
 
231
        if( left == NIL ) { 
235
        if( tree.left == NIL && tree.right == NIL ) { return NIL; }
232
            tempKey = key;
236
        if( tree.left == NIL ) { 
233
            
-
 
234
            //same as "this = new AVLTree(right.key,right.left,right.right);"
237
            return new AVLTree(tree.right.key,tree.right.data,
235
            AVLTree temp = new AVLTree(right.key,right.data,right.left,right.right);
238
                               tree.right.left,tree.right.right); 
236
            setThis(temp);
-
 
237
        }
239
        }
238
        if( left.left == NIL && left.right == NIL ) {
-
 
239
            tempKey = key;
-
 
240
            
-
 
241
            //same as "this = new AVLTree(left.key,left.left,right.right);"
-
 
242
            AVLTree temp = new AVLTree(left.key,left.data,left.left,right.right);
240
        return new AVLTree(tree.key,tree.data,deleteMinimum(tree.left),tree.right);
243
            setThis(temp);
-
 
244
        }
-
 
245
        return deleteMinimum(left);
-
 
246
    }
241
    }
247
    
242
    
248
    */
243
    
249
    private void setThis( AVLTree that ) {
244
    private void setThis( AVLTree that ) {
250
        this.key = that.key;
245
        this.key = that.key;
251
        this.data = that.data;
246
        this.data = that.data;
252
        this.height = that.height;
247
        this.height = that.height;
253
        this.left = that.left;
248
        this.left = that.left;