Metodo para contar o num de folhas numa BST

1 resposta
M

oi pessoal

o meu metodo conta o numero folhas numa BST mas esta a folhar porque???

private int contaNumFolhas(BSTNodo tree)
{ if(tree.left==null&&tree.right==null) return 1;

if(tree.left==null||tree.right==null) return 1;
   
     if(tree.right==null) return 1;
        else
        return 	contaNumFolhas(tree.left)+contaNumFolhas(tree.right);

}

1 Resposta

T

Alguma coisa não deveria retornar 0 aí?

Criado 15 de outubro de 2007
Ultima resposta 15 de out. de 2007
Respostas 1
Participantes 2