plano
This commit is contained in:
parent
ca631b1082
commit
496b5f3465
Binary file not shown.
Binary file not shown.
|
|
@ -9,7 +9,6 @@ public class Agenda {
|
||||||
//inserir todas as 26 letras do alfabeto...
|
//inserir todas as 26 letras do alfabeto...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean pesquisarNome(String nome) {
|
public boolean pesquisarNome(String nome) {
|
||||||
return pesquisarNome(raiz, nome);
|
return pesquisarNome(raiz, nome);
|
||||||
}
|
}
|
||||||
|
|
@ -69,14 +68,14 @@ public class Agenda {
|
||||||
return pesquisar(raiz, cpf);
|
return pesquisar(raiz, cpf);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean pesquisar(No i, int cpf) {
|
private boolean pesquisar(No no, int cpf) {
|
||||||
boolean resp = false;
|
boolean resp = false;
|
||||||
if (i != null) {
|
if (no != null) {
|
||||||
resp = pesquisar(i.primeiro.prox, cpf);
|
resp = pesquisar(no.primeiro.prox, cpf);
|
||||||
if(resp == false){
|
if(resp == false){
|
||||||
resp = pesquisar(i.esq, cpf);
|
resp = pesquisar(no.esq, cpf);
|
||||||
if(resp == false){
|
if(resp == false){
|
||||||
resp = pesquisar(i.dir, cpf);
|
resp = pesquisar(no.dir, cpf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,15 +44,25 @@ public class Principal {
|
||||||
* arvore.mostrarPre();
|
* arvore.mostrarPre();
|
||||||
*/
|
*/
|
||||||
arvore.inserir(4);
|
arvore.inserir(4);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(35);
|
arvore.inserir(35);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(10);
|
arvore.inserir(10);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(13);
|
arvore.inserir(13);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(3);
|
arvore.inserir(3);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(30);
|
arvore.inserir(30);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(15);
|
arvore.inserir(15);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(12);
|
arvore.inserir(12);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(7);
|
arvore.inserir(7);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(40);
|
arvore.inserir(40);
|
||||||
|
arvore.caminharPre();
|
||||||
arvore.inserir(20);
|
arvore.inserir(20);
|
||||||
arvore.caminharPre();
|
arvore.caminharPre();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,13 +46,11 @@ class DoidonaComTADsProntas {
|
||||||
} else if(t1[i] == NULO){
|
} else if(t1[i] == NULO){
|
||||||
t1[i] = elemento;
|
t1[i] = elemento;
|
||||||
}else if(hashT2(elemento) == 0){
|
}else if(hashT2(elemento) == 0){
|
||||||
int i = hashT3(elemento);
|
i = hashT3(elemento);
|
||||||
|
|
||||||
if(t3[i] == NULO){
|
if(t3[i] == NULO){
|
||||||
t3[i] = elemento;
|
t3[i] = elemento;
|
||||||
} else {
|
} else {
|
||||||
i = rehashT3(elemento);
|
i = rehashT3(elemento);
|
||||||
|
|
||||||
if(t3[i] == NULO){
|
if(t3[i] == NULO){
|
||||||
t3[i] = elemento;
|
t3[i] = elemento;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -67,32 +65,34 @@ class DoidonaComTADsProntas {
|
||||||
System.out.println("ERRO!!!!");
|
System.out.println("ERRO!!!!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void remover (int valor){
|
void remover (int elemento){
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean pesquisar (int valor){
|
boolean pesquisar (int elemento){
|
||||||
boolean resp = false;
|
boolean resp = false;
|
||||||
int pos = hashT1(valor);
|
int pos = hashT1(elemento);
|
||||||
if(t1[pos] == valor){
|
if(elemento == NULO){
|
||||||
|
resp = false;
|
||||||
|
} else if(t1[pos] == elemento){
|
||||||
resp = true;
|
resp = true;
|
||||||
}else {
|
}else {
|
||||||
pos = hashT2(valor);
|
pos = hashT2(elemento);
|
||||||
if (pos == 0){
|
if (pos == 0){
|
||||||
pos = hashT3(valor);
|
pos = hashT3(elemento);
|
||||||
if(t3[pos] == valor){
|
if(t3[pos] == elemento){
|
||||||
resp = true;
|
resp = true;
|
||||||
}else{
|
}else{
|
||||||
pos = rehashT3(valor);
|
pos = rehashT3(elemento);
|
||||||
if(t3[pos] == valor){
|
if(t3[pos] == elemento){
|
||||||
resp = true;
|
resp = true;
|
||||||
}else{
|
}else{
|
||||||
resp = arvoreBinaria.pesquisar(valor);
|
resp = arvoreBinaria.pesquisar(elemento);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if (pos == 1){
|
}else if (pos == 1){
|
||||||
resp = lista.pesquisar(valor);
|
resp = lista.pesquisar(elemento);
|
||||||
} else {
|
} else {
|
||||||
resp = arvoreAVL.pesquisar(valor);
|
resp = arvoreAVL.pesquisar(elemento);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resp;
|
return resp;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ class Principal {
|
||||||
arv.inserir(array[i]);
|
arv.inserir(array[i]);
|
||||||
}
|
}
|
||||||
arv.mostrar();
|
arv.mostrar();
|
||||||
|
/*
|
||||||
for(int i = 0; i < array.length; i++){
|
for(int i = 0; i < array.length; i++){
|
||||||
System.out.println("Pesquisar(" + array[i] + "):" + arv.pesquisar(array[i]));
|
System.out.println("Pesquisar(" + array[i] + "):" + arv.pesquisar(array[i]));
|
||||||
}
|
}
|
||||||
|
|
@ -28,6 +29,7 @@ class Principal {
|
||||||
|
|
||||||
s = "gaga";
|
s = "gaga";
|
||||||
System.out.println("Pesquisar(" + s + "):" + arv.pesquisar(s));
|
System.out.println("Pesquisar(" + s + "):" + arv.pesquisar(s));
|
||||||
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue