I cannot figure out why this function is not working. Evertime I try to make the recursive call all I get is an IE page with a cannot display error message. I left // by the lines that is causing me the trouble. I also tried the call without the $this-> and got an error function not recognized
private function insert($key, $current) {
$newnode=new Node($key);
$parent=$this->root;
if($this->root==null) {
$this->root=$newnode;
return;
} else {
if($newnode->data > $parent->data) {
$parent=$parent->rightChild;
$this->insert($key, $parent);//if I comment this line it
//work, but that make the function useless
} else {
echo "smaller ";
}
}
}
$newnode->data > $parent->dataalways true?ifandelseblocks. Leaving them out leads to confusion and possibly incorrect control flow