Skip to content

Commit

Permalink
rotacaoD
Browse files Browse the repository at this point in the history
  • Loading branch information
andore committed Nov 18, 2014
1 parent e2286b3 commit e5e5d51
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Eletiva/entrada.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1 2 3 5 4 8 7 8 9 1 2 4 6 5 0
100 5 3 -2 99 4 -1 -3 0
15 changes: 7 additions & 8 deletions Eletiva/saida.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
1 2
2 2
-3 1
-2 1
-1 1
3 1
4 2
5 2
6 1
7 1
8 2
9 1
4 1
5 1
99 1
100 1
26 changes: 26 additions & 0 deletions Eletiva/src/arvore/Arvore.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ public void setRaiz(No raiz) {
}

public void rotacaoD (No no)
{
No temp = no.getPai();

if(no.getPai().getPai().getEsq()==no.getPai())
{
no.getPai().getPai().setEsq(no);
}
else
{
no.getPai().getPai().setDir(no);
}

no.setPai(no.getPai().getPai());
no.setN_elemento(no.getN_elemento() - 1);
no.getEsq().setN_elemento(no.getEsq().getN_elemento() - 1);

temp.setEsq(no.getDir());
no.getDir().setPai(temp);

no.setDir(temp);
temp.setPai(no);
temp.setN_elemento(temp.getN_elemento() + 1);
temp.getDir().setN_elemento(temp.getDir().getN_elemento() + 1);
}

public void rotacaoE (No no)
{

}
Expand Down
6 changes: 2 additions & 4 deletions Eletiva/src/exerArvore/ContFreqNum.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ public void preencheArvore() {
}
}
System.out.println("ARVORE PREENCHIDA");
}

public void rotacaoD (No no)
{

arvore.rotacaoD(arvore.getRaiz().getEsq().getEsq());
}


public void gravaArvore() {
StringBuffer arvoreString = new StringBuffer(arvore.toString());
grava = new GravaTxt(DIRETORIO_SAIDA, arvoreString);
Expand Down

0 comments on commit e5e5d51

Please sign in to comment.