All pastes #410486 Raw Edit

Something

public text v1 · immutable
#410486 ·published 2007-03-26 12:56 UTC
rendered paste body
REKURSIVT med referens:
    /**
     * Insert a new item in tree.
     * @param x the item to insert.
     */
    public void insert(E x) {
	insert(x, root);
    }

    /* Insert the element x into the subtree with root n */
    private void insert(E x, BinaryNode<E> &n) {
        if(n == null) {
            n = new BinaryNode<E>(x);
    	} elseif (n.getElement().compareTo(x) > 0) {
	    insert(x, n.getLeft());
	} else {
	    insert(x, n.getRight());
	}
    }