0
public void insert(Buchstabe pBuchstabe,char[] pChar,int pStelle)
{
    if(pBuchstabe==null)
        return;
    int Stelle = pStelle;
    if(baum.isEmpty())
    {
        baum=new BinaryTree(pBuchstabe);
    }
    else {
        if(pStelle < pChar.length)
        {
            if(pChar[Stelle] == '.')
            {
                Mybaum lTree=this.getLeftTree();
                Stelle++;
                lTree.insert(pBuchstabe,pChar,Stelle);
                this.baum.setLeftTree(lTree.baum);
            }
            else
            if(pChar[Stelle]=='-')
            {
                Mybaum rTree=this.getRightTree();
                Stelle++;
                rTree.insert(pBuchstabe,pChar,Stelle);
                this.baum.setLeftTree(rTree.baum);
            }
        }
        else
            return;
    }
}

So this is my insert Method. The Problem is that it only adds the last Buchstabe which i pass to it to the BinaryTree. So it will get a Buchstabe, a char Array with some '.' or '-' code in it and a integer which starts at 0 when the insert merhod is called at the beginning. There is no real error but i get this output : http://puu.sh/h9I4E/beee4f30a9.png . It should create a Binary Tree with 26 Items but only one is showing up on the wrong side.

2

1 Answer 1

1

I found the Problem it is the second Part of the insert it takes the left instead of the right tree.

 if(pChar[Stelle]=='-')
        {
            Mybaum rTree=this.getRightTree();
            Stelle++;
            rTree.insert(pBuchstabe,pChar,Stelle);
            this.baum.**setLeftTree**(rTree.baum);
        }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.