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 {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
void inserir(int x) throws Exception {
|
||||||
* 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 {
|
|
||||||
raiz = inserir(x, raiz);
|
raiz = inserir(x, raiz);
|
||||||
}
|
}
|
||||||
|
No inserir(int x, No i) throws Exception {
|
||||||
/**
|
|
||||||
* 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 {
|
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
i = new No(x);
|
i = new No(x);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ public class AVL {
|
||||||
no = rotacionarDir(no);
|
no = rotacionarDir(no);
|
||||||
|
|
||||||
}else{
|
}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;
|
noEsq.dir = no;
|
||||||
no.esq = noEsqDir;
|
no.esq = noEsqDir;
|
||||||
|
|
||||||
no.setNivel();
|
no.setNivel(); //Atualizar o nivel do no
|
||||||
noEsq.setNivel();
|
noEsq.setNivel(); //Atualizar o nivel do noEsq
|
||||||
|
|
||||||
return noEsq;
|
return noEsq;
|
||||||
}
|
}
|
||||||
|
|
@ -270,8 +270,8 @@ public class AVL {
|
||||||
noDir.esq = no;
|
noDir.esq = no;
|
||||||
no.dir = noDirEsq;
|
no.dir = noDirEsq;
|
||||||
|
|
||||||
no.setNivel();
|
no.setNivel(); //Atualizar o nivel do no
|
||||||
noDir.setNivel();
|
noDir.setNivel(); //Atualizar o nivel do noDir
|
||||||
return noDir;
|
return noDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue