Skip to content

Commit

Permalink
Arbol binario v3.5.0
Browse files Browse the repository at this point in the history
Inclusion de lista dinamica
  • Loading branch information
DiscoDurodeRoer committed Jun 23, 2018
1 parent 207b0f4 commit 92f7f35
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
Binary file added Arboles/lib/Lista_enlazada_v3.0.0.jar
Binary file not shown.
8 changes: 6 additions & 2 deletions Arboles/nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=Arboles
application.vendor=Fernando
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
Expand All @@ -26,10 +27,13 @@ dist.archive.excludes=
dist.dir=dist
dist.jar=${dist.dir}/Arboles.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.Lista_enlazada_v3.0.0.jar=lib/Lista_enlazada_v3.0.0.jar
includes=**
jar.compress=false
javac.classpath=
javac.classpath=\
${file.reference.Lista_enlazada_v3.0.0.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
Expand Down
66 changes: 66 additions & 0 deletions Arboles/src/arboles/binario/BinarySearchTree.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package arboles.binario;

import lista.simple.ListaDinamica;

/**
* Arbol binario de busqueda o BST
*
Expand Down Expand Up @@ -412,4 +414,68 @@ private NodoArbolBinario<T> minSubTree(NodoArbolBinario<T> nodo) {
return nodo;
}

public NodoArbolBinario<T> getNode(NodoArbolBinario<T> nodo, T elemento) {

NodoArbolBinario<T> aux = null;

if (nodo.getElement().compareTo(elemento) == 0) {
aux = nodo;
} else {
if (nodo.getLeft() != null) {
aux = getNode(nodo.getLeft(), elemento);
}

if (nodo.getRight() != null) {
aux = getNode(nodo.getRight(), elemento);
}
}

return aux;
}

public T getElement(NodoArbolBinario<T> nodo, T elemento) {

NodoArbolBinario<T> aux = getNode(nodo, elemento);

if (aux == null) {
return null;
}

return aux.getElement();
}

public void getNodes(NodoArbolBinario<T> nodo, T elemento, ListaDinamica<NodoArbolBinario<T>> lista_nodos) {

if (nodo.getElement().compareTo(elemento) == 0) {
lista_nodos.addLast(nodo);
}

if (nodo.getLeft() != null) {
getNodes(nodo.getLeft(), elemento, lista_nodos);
}

if (nodo.getRight() != null) {
getNodes(nodo.getRight(), elemento, lista_nodos);
}

}

public ListaDinamica<T> getElements(NodoArbolBinario<T> nodo, T elemento) {

ListaDinamica<T> elementos = new ListaDinamica<>();
ListaDinamica<NodoArbolBinario<T>> lista_nodos = new ListaDinamica<>();

getNodes(nodo, elemento, lista_nodos);

for(NodoArbolBinario<T> aux:lista_nodos){

elementos.addLast(aux.getElement());

}

return elementos;

}


}

0 comments on commit 92f7f35

Please sign in to comment.