arvore avl!
This commit is contained in:
parent
dea0b4ce77
commit
f39a412024
|
|
@ -169,7 +169,6 @@
|
|||
} else {
|
||||
i.esq = maiorEsq(i, i.esq);
|
||||
}
|
||||
|
||||
return balancear(i);
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +205,7 @@
|
|||
no.dir = rotacionarDir(no.dir);
|
||||
}
|
||||
no = rotacionarEsq(no);
|
||||
// Se desbalanceada para a esquerda
|
||||
// Se desbalanceada para a esquerda
|
||||
} else if (fator == -2) {
|
||||
int fatorFilhoEsq = No.getNivel(no.esq.dir) - No.getNivel(no.esq.esq);
|
||||
// Se o filho a esquerda tambem estiver desbalanceado
|
||||
|
|
@ -223,7 +222,7 @@
|
|||
}
|
||||
|
||||
private No rotacionarDir(No no) {
|
||||
//System.out.println("Rotacionar DIR(" + no.elemento + ")");
|
||||
System.out.println("Rotacionar DIR(" + no.elemento + ")");
|
||||
No noEsq = no.esq;
|
||||
No noEsqDir = noEsq.dir;
|
||||
|
||||
|
|
@ -237,7 +236,7 @@
|
|||
}
|
||||
|
||||
private No rotacionarEsq(No no) {
|
||||
//System.out.println("Rotacionar ESQ(" + no.elemento + ")");
|
||||
System.out.println("Rotacionar ESQ(" + no.elemento + ")");
|
||||
No noDir = no.dir;
|
||||
No noDirEsq = noDir.esq;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ public class Principal {
|
|||
try {
|
||||
AVL avl = new AVL();
|
||||
int array[] = {4,35,10,13,3,30,15,12,7,40,20};
|
||||
//int array[] = {1,2,3,4,5,6,7,8,9,10};
|
||||
for(int item: array){
|
||||
System.out.println("Inserindo -> " + item);
|
||||
avl.inserir(item);
|
||||
|
|
|
|||
Loading…
Reference in New Issue