update
This commit is contained in:
parent
7962c3b68b
commit
1494c7093b
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -110,23 +110,10 @@ public class ArvoreBinaria {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Metodo publico iterativo para inserir elemento.
|
||||
* @param x Elemento a ser inserido.
|
||||
* @throws Exception Se o elemento existir.
|
||||
*/
|
||||
public void inserir(int x) throws Exception {
|
||||
void inserir(int x) throws Exception {
|
||||
raiz = inserir(x, raiz);
|
||||
}
|
||||
|
||||
/**
|
||||
* Metodo privado recursivo para inserir elemento.
|
||||
* @param x Elemento a ser inserido.
|
||||
* @param i No em analise.
|
||||
* @return No em analise, alterado ou nao.
|
||||
* @throws Exception Se o elemento existir.
|
||||
*/
|
||||
private No inserir(int x, No i) throws Exception {
|
||||
No inserir(int x, No i) throws Exception {
|
||||
if (i == null) {
|
||||
i = new No(x);
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ public class AVL {
|
|||
no = rotacionarDir(no);
|
||||
|
||||
}else{
|
||||
throw new Exception("Erro fator de balanceamento (" + fator + ") invalido!");
|
||||
throw new Exception("Erro no No(" + no.elemento + ") com fator de balanceamento (" + fator + ") invalido!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,8 +256,8 @@ public class AVL {
|
|||
noEsq.dir = no;
|
||||
no.esq = noEsqDir;
|
||||
|
||||
no.setNivel();
|
||||
noEsq.setNivel();
|
||||
no.setNivel(); //Atualizar o nivel do no
|
||||
noEsq.setNivel(); //Atualizar o nivel do noEsq
|
||||
|
||||
return noEsq;
|
||||
}
|
||||
|
|
@ -270,8 +270,8 @@ public class AVL {
|
|||
noDir.esq = no;
|
||||
no.dir = noDirEsq;
|
||||
|
||||
no.setNivel();
|
||||
noDir.setNivel();
|
||||
no.setNivel(); //Atualizar o nivel do no
|
||||
noDir.setNivel(); //Atualizar o nivel do noDir
|
||||
return noDir;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue