diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..7cf63b7 --- /dev/null +++ b/build.xml @@ -0,0 +1,53 @@ + + Builds, tests, and runs the project ArbolAVL. + + + diff --git a/build/built-jar.properties b/build/built-jar.properties new file mode 100644 index 0000000..2aa67b9 --- /dev/null +++ b/build/built-jar.properties @@ -0,0 +1,4 @@ +#Tue, 04 Feb 2020 11:28:30 -0500 + + +C\:\\Users\\CORE\ i7\ ULTIMATE\\OneDrive\ -\ Escuela\ Superior\ Polit\u00e9cnica\ del\ Litoral\\ESTRUCTURAS\ DE\ DATOS\\ProyectosSegundoParcial\\Proyecto2\\avl\\ArbolAVL= diff --git a/build/classes/.scannerwork/.sonar_lock b/build/classes/.scannerwork/.sonar_lock new file mode 100644 index 0000000..e69de29 diff --git a/build/classes/.scannerwork/report-task.txt b/build/classes/.scannerwork/report-task.txt new file mode 100644 index 0000000..4b592d8 --- /dev/null +++ b/build/classes/.scannerwork/report-task.txt @@ -0,0 +1,6 @@ +projectKey=AlexVelez:AVLTree +serverUrl=http://200.9.176.59:9000 +serverVersion=7.7.0.23042 +dashboardUrl=http://200.9.176.59:9000/dashboard?id=AlexVelez%3AAVLTree +ceTaskId=AW_-MyTuvXyWqgoFqhI9 +ceTaskUrl=http://200.9.176.59:9000/api/ce/task?id=AW_-MyTuvXyWqgoFqhI9 diff --git a/build/classes/Interfaz/Index.class b/build/classes/Interfaz/Index.class new file mode 100644 index 0000000..844feae Binary files /dev/null and b/build/classes/Interfaz/Index.class differ diff --git a/build/classes/Interfaz/InterfazArbol.class b/build/classes/Interfaz/InterfazArbol.class new file mode 100644 index 0000000..12ae8bb Binary files /dev/null and b/build/classes/Interfaz/InterfazArbol.class differ diff --git a/build/classes/sonar-project.properties b/build/classes/sonar-project.properties new file mode 100644 index 0000000..64b0cdd --- /dev/null +++ b/build/classes/sonar-project.properties @@ -0,0 +1,17 @@ +sonar.host.url=http://200.9.176.59:9000 +sonar.projectKey=AlexVelez:AVLTree +# must be unique in a given SonarQube instance +sonar.login=avelez2019 +sonar.password=201808680 +# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. +sonar.projectName=AVLTree +sonar.projectVersion=1.0 +# Path is relative to the sonar-project.properties file. Replace "\" by "/" onWindows. +# This property is optional if sonar.modules is set. +sonar.sources=. +sonar.java.binaries=../build +sonar.scm.disabled=true + +#Nombre_Proyecto : Es el nombre del proyecto que analizar\u00c3\u00a1n Ej: "SimplyLinkedList" +#Usuario: Es su usuario asignado, enviado por Sidweb en un archivo excel +#Matr\u00c3\u00adcula: Es su n\u00c3\u00bamero de matr\u00c3\u00adcula \ No newline at end of file diff --git a/build/classes/tda/AVL.class b/build/classes/tda/AVL.class new file mode 100644 index 0000000..caa9935 Binary files /dev/null and b/build/classes/tda/AVL.class differ diff --git a/build/classes/tda/Nodo.class b/build/classes/tda/Nodo.class new file mode 100644 index 0000000..a9adb42 Binary files /dev/null and b/build/classes/tda/Nodo.class differ diff --git a/dist/ArbolAVL.html b/dist/ArbolAVL.html new file mode 100644 index 0000000..a2efc1d --- /dev/null +++ b/dist/ArbolAVL.html @@ -0,0 +1,45 @@ + + + + + + + +

Test page for ArbolAVL

+ Webstart: click to launch this app as webstart


+ + +
+ diff --git a/dist/ArbolAVL.jar b/dist/ArbolAVL.jar new file mode 100644 index 0000000..2ac4fc0 Binary files /dev/null and b/dist/ArbolAVL.jar differ diff --git a/dist/ArbolAVL.jnlp b/dist/ArbolAVL.jnlp new file mode 100644 index 0000000..ebfbeb5 --- /dev/null +++ b/dist/ArbolAVL.jnlp @@ -0,0 +1,18 @@ + + + + ArbolAVL + kmmarin + null + + + + + + + + + + + + diff --git a/dist/web-files/dtjava.js b/dist/web-files/dtjava.js new file mode 100644 index 0000000..b77ecd7 --- /dev/null +++ b/dist/web-files/dtjava.js @@ -0,0 +1,3958 @@ +/* + * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/** + The Java Deployment Toolkit is a utility to deploy Java content in + the browser as applets or applications using the right version of Java. + If needed it can initiate an upgrade of user's system to install required + components of Java platform. +

+ Note that some of the Deployment Toolkit methods may not be fully operational if + used before web page body is loaded (because DT native plugins could not be instantiated). + If you intend to use it before web page DOM tree is ready then dtjava.js + needs to be loaded inside the body element of the page and before use of other DT APIs. + + @module java/deployment_toolkit +*/ +var dtjava = function() { + function notNull(o) { + return (o != undefined && o != null); + } + + function isDef(fn) { + return (fn != null && typeof fn != "undefined"); + } + + //return true if any of patterns from query list is found in the given string + function containsAny(lst, str) { + for (var q = 0; q < lst.length; q++) { + if (str.indexOf(lst[q]) != -1) { + return true; + } + } + return false; + } + + /* Location of static web content - images, javascript files. */ + var jscodebase = (function () { + // + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/jfx-impl_backup.xml b/nbproject/jfx-impl_backup.xml new file mode 100644 index 0000000..a178f19 --- /dev/null +++ b/nbproject/jfx-impl_backup.xml @@ -0,0 +1,4007 @@ + + + + + JavaFX-specific Ant calls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${cssfileslist} + + + + + + + + + + + + + + + + + + + + + + + + self.addMappedName( + (source.indexOf("jfxrt.jar") >= 0) || + (source.indexOf("deploy.jar") >= 0) || + (source.indexOf("javaws.jar") >= 0) || + (source.indexOf("plugin.jar") >= 0) + ? "" : source + ); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/private/configs/Run_as_WebStart.properties b/nbproject/private/configs/Run_as_WebStart.properties new file mode 100644 index 0000000..86ae865 --- /dev/null +++ b/nbproject/private/configs/Run_as_WebStart.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=webstart diff --git a/nbproject/private/configs/Run_in_Browser.properties b/nbproject/private/configs/Run_in_Browser.properties new file mode 100644 index 0000000..f4e8549 --- /dev/null +++ b/nbproject/private/configs/Run_in_Browser.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=embedded diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..6b37984 --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,2 @@ +auxiliary.org-netbeans-modules-projectapi.issue214819_5f_fx_5f_enabled=true +user.properties.file=C:\\Users\\CORE i7 ULTIMATE\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..6807a2b --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..3978087 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,115 @@ +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=ArbolAVL +application.vendor=kmmarin +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +compile.on.save=true +compile.on.save.unsupported.javafx=true +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/ArbolAVL.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +includes=** +# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects +jar.archive.disabled=true +jar.compress=false +javac.classpath=\ + ${javafx.classpath.extension} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit_4.classpath}:\ + ${libs.hamcrest.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +javafx.application.implementation.version=1.0 +javafx.binarycss=false +javafx.classpath.extension=\ + ${java.home}/lib/javaws.jar:\ + ${java.home}/lib/deploy.jar:\ + ${java.home}/lib/plugin.jar +javafx.deploy.allowoffline=true +# If true, application update mode is set to 'background', if false, update mode is set to 'eager' +javafx.deploy.backgroundupdate=false +javafx.deploy.embedJNLP=true +javafx.deploy.includeDT=true +# Set true to prevent creation of temporary copy of deployment artifacts before each run (disables concurrent runs) +javafx.disable.concurrent.runs=false +# Set true to enable multiple concurrent runs of the same WebStart or Run-in-Browser project +javafx.enable.concurrent.external.runs=false +# This is a JavaFX project +javafx.enabled=true +javafx.fallback.class=com.javafx.main.NoJavaFXFallback +# Main class for JavaFX +javafx.main.class=Interfaz.Index +javafx.preloader.class= +# This project does not use Preloader +javafx.preloader.enabled=false +javafx.preloader.jar.filename= +javafx.preloader.jar.path= +javafx.preloader.project.path= +javafx.preloader.type=none +# Set true for GlassFish only. Rebases manifest classpaths of JARs in lib dir. Not usable with signed JARs. +javafx.rebase.libs=false +javafx.run.height=600 +javafx.run.width=800 +# Pre-JavaFX 2.0 WebStart is deactivated in JavaFX 2.0+ projects +jnlp.enabled=false +# Main class for Java launcher +main.class=com.javafx.main.Main +# For improved security specify narrower Codebase manifest attribute to prevent RIAs from being repurposed +manifest.custom.codebase=* +# Specify Permissions manifest attribute to override default (choices: sandbox, all-permissions) +manifest.custom.permissions= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +platform.active=default_platform +run.classpath=\ + ${dist.jar}:\ + ${javac.classpath}:\ + ${build.classes.dir} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..cea48a1 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,25 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + + + + + + + + ArbolAVL + + + + + + + + + diff --git a/src/.scannerwork/.sonar_lock b/src/.scannerwork/.sonar_lock new file mode 100644 index 0000000..e69de29 diff --git a/src/.scannerwork/report-task.txt b/src/.scannerwork/report-task.txt new file mode 100644 index 0000000..4b592d8 --- /dev/null +++ b/src/.scannerwork/report-task.txt @@ -0,0 +1,6 @@ +projectKey=AlexVelez:AVLTree +serverUrl=http://200.9.176.59:9000 +serverVersion=7.7.0.23042 +dashboardUrl=http://200.9.176.59:9000/dashboard?id=AlexVelez%3AAVLTree +ceTaskId=AW_-MyTuvXyWqgoFqhI9 +ceTaskUrl=http://200.9.176.59:9000/api/ce/task?id=AW_-MyTuvXyWqgoFqhI9 diff --git a/src/Interfaz/Index.java b/src/Interfaz/Index.java new file mode 100644 index 0000000..03a4189 --- /dev/null +++ b/src/Interfaz/Index.java @@ -0,0 +1,31 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Interfaz; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; + +/** + * + * @author CORE i7 ULTIMATE + */ +public class Index extends Application{ + public static void main(String [] args){ + launch(args); + } + + @Override + public void start(Stage primaryStage) throws Exception { + InterfazArbol ia = new InterfazArbol(); + Scene sc = new Scene(ia.getRoot(),1366,768); + primaryStage.setScene(sc); + primaryStage.setFullScreen(true); + primaryStage.setResizable(false); + primaryStage.show(); + + } +} diff --git a/src/Interfaz/InterfazArbol.java b/src/Interfaz/InterfazArbol.java new file mode 100644 index 0000000..19b28a3 --- /dev/null +++ b/src/Interfaz/InterfazArbol.java @@ -0,0 +1,151 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package Interfaz; + +import java.util.ArrayList; +import javafx.application.Platform; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.shape.Circle; +import javafx.scene.shape.LineTo; +import javafx.scene.shape.MoveTo; +import javafx.scene.shape.Path; +import javafx.scene.shape.PathElement; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.FontPosture; +import javafx.scene.text.FontWeight; +import tda.AVL; + +/** + * + * @author CORE i7 ULTIMATE + */ +public class InterfazArbol { + private Pane root; + private AVL avlTree; + private ScrollPane sp; + + public InterfazArbol(){ + root = new VBox(); + avlTree = new AVL<>(Integer::compareTo); + sp = new ScrollPane(); + + createRoot(); + } + + private void createRoot(){ + Rectangle topRect = new Rectangle(1366,75); + topRect.setFill(Color.DARKCYAN); + Label lblAvl = new Label("AVL TREE"); + lblAvl.setTranslateX(30); + lblAvl.setTranslateY(20); + Font theFont = Font.font("arial", FontWeight.EXTRA_BOLD, 40); + lblAvl.setFont(theFont); + lblAvl.setTextFill(Color.WHITE); + Pane topPane = new Pane(); + topPane.getChildren().addAll(topRect,lblAvl); + HBox hbOpc = new HBox(); + hbOpc.setAlignment(Pos.CENTER); + hbOpc.setTranslateY(6); + TextField txtInsertar = new TextField(); + Button btnInsertar = new Button("Insertar"); + TextField txtDelete = new TextField(); + Button btnDelete = new Button("Eliminar"); + HBox hbInst = new HBox(); + hbInst.getChildren().addAll(txtInsertar,btnInsertar); + hbInst.setSpacing(5); + HBox hbDel = new HBox(); + hbDel.getChildren().addAll(txtDelete,btnDelete); + hbDel.setSpacing(5); + Button btnClear = new Button("Clear"); + Pane pnClear = new Pane(btnClear); + hbOpc.getChildren().addAll(hbInst,hbDel,pnClear); + hbOpc.setSpacing(30); + Rectangle optRect = new Rectangle(1366,40); + optRect.setOpacity(0.7); + optRect.setFill(Color.CADETBLUE); + StackPane optStck = new StackPane(); + optStck.getChildren().addAll(optRect,hbOpc); + StackPane arbol = new StackPane(); + arbol.setMinHeight(200); + arbol.setMinWidth(1366); + btnClear.setOnMouseClicked(e->{ + avlTree = new AVL<>(Integer::compareTo); + arbol.getChildren().clear(); + Pane avlPane = avlTree.mostrarArbol(); + arbol.getChildren().add(avlPane); + arbol.setMinWidth(avlTree.height()*100); + }); + sp.setContent(arbol); + sp.setMinHeight(500); + sp.setMaxHeight(500); + btnInsertar.setOnAction(e->{ + Integer num=0; + try{ + num = Integer.parseInt(txtInsertar.getText()); + txtInsertar.setText(""); + txtInsertar.requestFocus(); + avlTree.Insert(num); + + arbol.getChildren().clear(); + Pane avlPane = avlTree.mostrarArbol(); + if(avlTree.height()<=7) avlPane.setTranslateX(100*(7-avlTree.height())); + arbol.getChildren().add(avlPane); + arbol.setMinWidth(avlTree.height()*100); + }catch(Exception ex){ + + } + + }); + + btnDelete.setOnMouseClicked(e->{ + Integer num=0; + try{ + num = Integer.parseInt(txtDelete.getText()); + txtDelete.setText(""); + txtDelete.requestFocus(); + avlTree.delete(num); + arbol.getChildren().clear(); + Pane avlPane = avlTree.mostrarArbol(); + if(avlTree.height()<=7) avlPane.setTranslateX(100*(7-avlTree.height())); + arbol.getChildren().add(avlPane); + arbol.setMinWidth(avlTree.height()*100); + + }catch(Exception ex){ + + } + }); + + + StackPane pnSalir = new StackPane(); + Label lblSalir = new Label("Salir"); + lblSalir.setFont(Font.font("Arial", FontWeight.BOLD, 40)); + lblSalir.setTextFill(Color.RED); + pnSalir.getChildren().add(lblSalir); + pnSalir.setOnMouseClicked(e->{ + Platform.exit(); + }); + pnSalir.setTranslateY(30); + pnSalir.setTranslateX(20); + + root.getChildren().addAll(topPane,optStck,sp,pnSalir); + + } + + + public Pane getRoot(){ + return root; + } +} diff --git a/src/sonar-project.properties b/src/sonar-project.properties new file mode 100644 index 0000000..64b0cdd --- /dev/null +++ b/src/sonar-project.properties @@ -0,0 +1,17 @@ +sonar.host.url=http://200.9.176.59:9000 +sonar.projectKey=AlexVelez:AVLTree +# must be unique in a given SonarQube instance +sonar.login=avelez2019 +sonar.password=201808680 +# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1. +sonar.projectName=AVLTree +sonar.projectVersion=1.0 +# Path is relative to the sonar-project.properties file. Replace "\" by "/" onWindows. +# This property is optional if sonar.modules is set. +sonar.sources=. +sonar.java.binaries=../build +sonar.scm.disabled=true + +#Nombre_Proyecto : Es el nombre del proyecto que analizar\u00c3\u00a1n Ej: "SimplyLinkedList" +#Usuario: Es su usuario asignado, enviado por Sidweb en un archivo excel +#Matr\u00c3\u00adcula: Es su n\u00c3\u00bamero de matr\u00c3\u00adcula \ No newline at end of file diff --git a/src/tda/AVL.java b/src/tda/AVL.java new file mode 100644 index 0000000..0da858b --- /dev/null +++ b/src/tda/AVL.java @@ -0,0 +1,821 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package tda; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Stack; +import javafx.scene.control.Label; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Circle; +import javafx.scene.shape.LineTo; +import javafx.scene.shape.MoveTo; +import javafx.scene.shape.Path; +import javafx.scene.shape.PathElement; + +/** + * Árbol binario de búsqueda, los elementos mayores estan a la derecha, + * @author kmmarin + */ +public class AVL { //AVL + + private Nodo root; + private Comparator f; + + public AVL(Comparator f) { + this.f = f; + this.root=null; + } + + public Nodo getRoot() { + return root; + } + + public void setRoot(Nodo root) { + this.root = root; + } + + public boolean isEmpty(){ + return root==null; + } + + public int height(){ + return height(root); + } + + /** + * Calcula la altura de un nodo + * @param n + * @return int + */ + private int height(Nodo n){ + if(n == null) + return 0; + return 1+ Math.max(height(n.getLeft()),height(n.getRight())); + } + + public int totalNodos(){ + return totalNodos(root); + } + + private int totalNodos(Nodo n){ + if (n==null) + return 0; + return 1 + totalNodos(n.getLeft())+ totalNodos(n.getRight()); + } + + public int contarHojas(){ + return contarHojas(root); + } + private int contarHojas(Nodo n){ + if(n==null) + return 0; + else if(n.getLeft()==null&& n.getRight()==null){ + return 1; + }return contarHojas(n.getLeft())+ contarHojas(n.getRight()); + } + + public boolean add(E element){ + if(element==null) + return false; + + this.root = add(element,root); + return true; + } + + private Nodo add(E element, Nodo n){ + if(n == null){ + n = new Nodo<>(element); + }else if(f.compare(element, n.getData()) > 0){ + n.setRight(add(element,n.getRight())); + }else if(f.compare(element, n.getData()) < 0){ + n.setLeft(add(element,n.getLeft())); + } + return n; + } + + public boolean Insert(E element){ + if(element==null) + return false; + this.root = Insert(element,root); + return true; + } + + private Nodo Insert(E element, Nodo n){ + if(n == null){ + n = new Nodo<>(element); + n.setFe(0); + }else if(f.compare(element, n.getData())>=0){ + n.setRight(Insert(element,n.getRight())); + n.setFe(this.calcularCarga(n)); + if(this.calcularCarga(n) >= 2 && this.calcularCarga(n.getRight()) == -1){ + n = this.rotacionDobleDerecha(n); + n.setFe(this.calcularCarga(n)); + }else if(this.calcularCarga(n) >= 1 && this.calcularCarga(n.getRight())==2){ + n.setRight(this.rotacionSimpleIzquierda(n.getRight())); + n.getRight().setFe(this.calcularCarga(n.getRight())); + }else if(this.calcularCarga(n) >= 2){ + n = this.rotacionSimpleIzquierda(n); + n.setFe(this.calcularCarga(n)); + } + }else if(f.compare(element, n.getData())<0){ + n.setLeft(Insert(element,n.getLeft())); + n.setFe(this.calcularCarga(n)); + if(calcularCarga(n) <= -2&& this.calcularCarga(n.getLeft())== 1){ + n = this.rotacionDobleIzquierda(n); + n.setFe(this.calcularCarga(n)); + }else if(this.calcularCarga(n) == -1 && this.calcularCarga(n.getLeft())== -2){ + n.setLeft(this.rotacionSimpleDerecha(n.getLeft())); + n.getLeft().setFe(this.calcularCarga(n.getLeft())); + }else if(this.calcularCarga(n) == -2){ + n = this.rotacionSimpleDerecha(n); + n.setFe(this.calcularCarga(n)); + } + } + return n; + } + + + public boolean esDegenerado(){ + return esDegenerado(root); + } + private boolean esDegenerado(Nodo p) { + if(p == null){ + return true; + } + else if(p.getLeft()!=null && p.getRight()!=null){ + return false; + } + return esDegenerado(p.getLeft())&& esDegenerado(p.getRight()); + } + + /** + * Calcula el Factor de Equilibrio: FE + * mide la carga del nodo. Puede ser 0, 1, 2, -1, -2 + * @return int + */ + public int calcularCarga(){ + return calcularCarga(root); + } + private int calcularCarga(Nodo n){ + if(n == null) + return -1; + int Carga = height(n.getRight()) - height(n.getLeft()); + return Carga; + } + + private Nodo searchNodo(E data){ + return searchNodo(data, root); + } + private Nodo searchNodo(E data, Nodo raiz){ + + if(raiz == null) + return raiz; + else if(raiz.getData().equals(data)) + return raiz; + else{ + Nodo l = searchNodo(data, raiz.getLeft()); + return (l != null) ? l: searchNodo(data, raiz.getRight()); + } + } + + /** + * Obtiene el nodo padre del nodo pasado por parametro. + * @param nodo + * @param raiz + * @return Nodo + */ + private Nodo BuscarPadre(Nodo nodo, Nodo raiz){ + Nodo nodoPapa = raiz; + if(nodo == null || nodoPapa == null || nodoPapa.getData() == nodo.getData()) + return nodo; + else if(nodoPapa.getRight() != null && nodoPapa.getLeft() != null){ + if(nodoPapa.getRight().getData() == nodo.getData() || nodoPapa.getLeft().getData() == nodo.getData()) + return nodoPapa; + else{ + Nodo p = BuscarPadre(nodo, nodoPapa.getRight()); + return (p != null) ? p: BuscarPadre(nodo, nodoPapa.getLeft()); + } + } + else if(nodoPapa.getRight() == null && nodoPapa.getLeft() != null){ + if(nodoPapa.getLeft().getData() == nodo.getData()) + return nodoPapa; + return BuscarPadre(nodo, nodoPapa.getLeft()); + }else if(nodoPapa.getRight() != null && nodoPapa.getLeft() == null){ + if(nodoPapa.getRight().getData() == nodo.getData()) + return nodoPapa; + return BuscarPadre(nodo, nodoPapa.getRight()); + } + return null; + } + + /** + * Realiza la operacion de rotacion simple derecha en el subarbol . + * Se ingresa el nodo que tiene carga 2 + * @param nodo raiz del subarbol a rotar. + * @return Nodo que pasa a ser la raiz del subarbol estructurado. + */ + public Nodo rotacionSimpleIzquierda(Nodo nodo){ + if(nodo == null) + return null; + Nodo nodoTemp; + + Nodo nodoPapa = nodo.getRight(); + nodo.setRight(null); + if(nodoPapa.getLeft() != null){ + nodoTemp = nodoPapa.getLeft(); + nodoPapa.setLeft(null); + nodo.setRight(nodoTemp); + } + nodoPapa.setLeft(nodo); + nodoPapa.getRight().setFe(this.calcularCarga(nodoPapa.getRight())); + nodoPapa.getLeft().setFe(this.calcularCarga(nodoPapa.getLeft())); + return nodoPapa; + } + + /** + * Realiza la operacion de rotacion simple izquierda en el subarbol + * que tiene como raiz el nodo pasado por parametro. + * @param nodo raiz del subarbol a rotar. + * + * @return nodo nodo que pasa a ser la raiz del subarbol estructurado. + */ + public Nodo rotacionSimpleDerecha(Nodo nodo){ + if(nodo == null) + return null; + Nodo nodoTemp; + + Nodo nodoPapa = nodo.getLeft(); + nodo.setLeft(null); + if(nodoPapa.getRight() != null){ + nodoTemp = nodoPapa.getRight(); + nodoPapa.setRight(null); + nodo.setLeft(nodoTemp); + } + nodoPapa.setRight(nodo); + nodoPapa.getRight().setFe(this.calcularCarga(nodoPapa.getRight())); + nodoPapa.getLeft().setFe(this.calcularCarga(nodoPapa.getLeft())); + return nodoPapa; + } + + public Nodo rotacionDobleIzquierda(Nodo nodo){ + if(nodo == null) + return null; + Nodo nodoTemp; + + Nodo nodoPapa = nodo.getLeft().getRight(); + nodoTemp = nodo.getLeft(); + nodo.setLeft(null); + nodoTemp.setRight(null); + nodoPapa.setLeft(nodoTemp); + nodoPapa.setRight(nodo); + + return nodoPapa; + } + + public Nodo rotacionDobleDerecha(Nodo nodo){ + if(nodo == null) + return null; + Nodo nodoTemp; + + Nodo nodoPapa = nodo.getRight().getLeft(); + nodoTemp = nodo.getRight(); + nodo.setRight(null); + nodoTemp.setLeft(null); + nodoPapa.setRight(nodoTemp); + nodoPapa.setLeft(nodo); + return nodoPapa; + } + + public E max(){ + return max(root); + } + private E max(Nodo n){ + if(n==null)return null; + else if(n.getRight()==null){ + return n.getData(); + }else + return max(n.getRight()); + } + + public E min(){ + return min(root); + } + private E min(Nodo n){ + if(n==null)return null; + else if(n.getLeft()==null){ + return n.getData(); + }else + return min(n.getLeft()); + } + + public boolean contains(E element){ + if(element==null|| isEmpty()) return false; + return contains(element,root); + + } + + private boolean contains(E element, Nodo n){ + if(n==null) return false; + else if(f.compare(element,n.getData()) == 0) + return true; + else if(f.compare(element, n.getData())>0){ + contains(element,n.getRight()); + }else if(f.compare(element, n.getData())<0){ + contains(element,n.getLeft()); + }return true; + } + + public void posOrde(){ + posOrden(root); + } + private void posOrden(Nodo n){ + if(n!=null){ + posOrden(n.getLeft()); + posOrden(n.getRight()); + System.out.println(n.getData()); + } + } + + public void preOrden(){ + preOrden(root); + } + private void preOrden(Nodo n){ + if(n!=null){ + System.out.println(n.getData()); + preOrden(n.getLeft()); + preOrden(n.getRight()); + } + } + + public void enOrden(){ + enOrden(root); + } + private void enOrden(Nodo n){ + if(n!=null){ + enOrden(n.getLeft()); + System.out.println(n.getData()); + enOrden(n.getRight()); + } + } + + public int nivel(E element){ + if (element==null|| isEmpty()|| this.contains(element)) return -1; + return nivel(element, root); + } + + private int nivel(E element, Nodo n){ + int num=height()-1; + if(n==null) return -1; + else if(f.compare(element,n.getData()) == 0){ + return num; + }else if(f.compare(element, n.getData())>0){ + return nivel(element,n.getRight())-1; + }else if(f.compare(element, n.getData())<0){ + return nivel(element,n.getLeft())-1; + }return -1; + } + + @Override + public boolean equals(Object obj) { + if (this == null || obj == null) + return false; + else if (!(this instanceof AVL) || !(obj instanceof AVL)){ + return false; + } + final AVL other = (AVL) obj; + return equals(this.root,other.root); + } + private boolean equals(Nodo n1, Nodo n2){ + if(n1 == null && n2 == null) + return true; + else if((n1 == null && n2 != null) || (n1 != null && n2 == null)) + return false; + else if(!n1.getData().equals(n2.getData())) { + return false; + } + + return equals(n1.getLeft(), n2.getLeft()) && equals(n1.getRight(), n2.getRight()); + } + + @Override + public int hashCode() { + return super.hashCode(); //To change body of generated methods, choose Tools | Templates. + } + public Pane mostrarArbol(){ + Pane vbArbol = new Pane(); + Pane lineas = new Pane(); + + mostrarArbol(vbArbol,root,0); + for(int i = 0;i n, int nivel){ + HBox hb; + if(idexOutOfBoundsException(vb,nivel)){ + hb = new HBox(); + hb.setTranslateY(70*nivel); + vb.getChildren().add(hb); + + }else hb = (HBox)vb.getChildren().get(nivel); + Circle cir = new Circle(20); + cir.setFill(Color.CHOCOLATE); + StackPane st = new StackPane(); + st.getChildren().add(cir); + hb.getChildren().add(st); + if(n!=null){ + Label lbl = new Label(n.getData().toString()); + lbl.setTextFill(Color.WHITE); + st.getChildren().add(lbl); + mostrarArbol(vb,n.getLeft(),nivel+1); + mostrarArbol(vb,n.getRight(),nivel+1); + }else{ + + cir.setOpacity(0); + if(nivel borrar=null,mirar=null,cambiar=null, nPadre = null; + Nodo raizTmp = this.getRoot(); + E c_aux, d_aux; + boolean salir = false; + int altDer = 0; + int altIzq = 0; + int a = 0; + + if(this.isEmpty()){ + return false; + } + + //el nodo a borrar es la raiz? + if(this.compararDato((E)o, raizTmp.getData())==0){ + salir = true; + borrar = raizTmp; + } + + //si no es la raiz, lo buscamos + while(!salir && (raizTmp.getRight()!=null || raizTmp.getLeft()!=null)){ + + if(this.compararDato((E)o, raizTmp.getData())>0){ + if(raizTmp.getRight()!=null){ + raizTmp = raizTmp.getRight(); + }else{ + return false; + } + }else if(this.compararDato((E)o, raizTmp.getData())<0){ + + if(raizTmp.getLeft()!=null){ + raizTmp = raizTmp.getLeft(); + }else{ + return false; + } + } + + if(this.compararDato((E)o, raizTmp.getData())==0){ + salir = true; + borrar = raizTmp; + } + } + + + //existe el nodo a borrar? + if(salir){ + mirar = borrar; + + //Hoja + if(borrar.getLeft()==null && borrar.getRight()==null){ + mirar= padre(borrar); + nPadre = padre(borrar); + + //es un arbol raiz con solo un nodo raiz? + if(this.size()==1){ + this.root = null; + } + + if(nPadre.getLeft()!=null && compararDato(nPadre.getLeft().getData(), borrar.getData())==0){ + nPadre.setLeft(null); + }else if(nPadre.getRight()!=null && compararDato(nPadre.getRight().getData(), borrar.getData())==0){ + nPadre.setRight(null); + } + + borrar.setData(null); + } + + + else if(borrar.getAltura()<=2){ + + if(borrar.getLeft()!=null){ + borrar.setData(borrar.getLeft().getData()); + borrar.setLeft(null); + } + + else if(borrar.getRight()!=null){ + borrar.setData(borrar.getRight().getData()); + borrar.setRight(null); + } + } + + //Nodo no hoja + else{ + + //mayor de la izquierda + if(borrar.getLeft()!=null){ + cambiar = borrar.getLeft(); + + while(cambiar.getRight()!=null){ + cambiar = cambiar.getRight(); + } + } + + //menor de la derecha + else if(borrar.getRight()!=null){ + //cambiar = cambiar.getRight();//cambio + cambiar = borrar.getRight(); + while(cambiar.getLeft()!=null){ + cambiar = cambiar.getLeft(); + } + } + + c_aux = cambiar.getData(); + Nodo papa = padre(cambiar); + + + if(cambiar.getLeft()!=null || cambiar.getRight()!=null){ + if(cambiar.getLeft()!=null){ + cambiar.setData(cambiar.getLeft().getData()); + cambiar.setLeft(null); + }else if(cambiar.getRight()!=null){ + cambiar.setData(cambiar.getRight().getData()); + cambiar.setRight(null); + } + } + + else{ + if(papa.getLeft()!=null && compararDato(papa.getLeft().getData(), cambiar.getData())==0){ + papa.setLeft(null); + }else{ + papa.setRight(null); + } + cambiar.setData(borrar.getData()); + borrar.setData(c_aux); + } + } + + while(equilibrado(this.getRoot())<0){ + if(mirar.getRight()==null){ + altDer = 0; + }else{ + altDer = mirar.getRight().getAltura(); + } + + if(mirar.getLeft()==null){ + altIzq = 0; + }else{ + altIzq = mirar.getLeft().getAltura(); + } + + Nodo cambiar2 = estructurar(mirar, altIzq, altDer); + Nodo superior = padre(mirar); + + + if(compararDato(superior.getData(), mirar.getData())!=0){ + if(superior.getLeft()!=null && compararDato(superior.getLeft().getData(), mirar.getData())==0){ + superior.setLeft(cambiar2); + } + else if(superior.getRight()!=null && compararDato(superior.getRight().getData(), mirar.getData())==0){ + superior.setRight(cambiar2); + } + }else{ + this.root = cambiar2; + } + mirar = padre(mirar); + } + return true; + } + return false; + } + private int compararDato(E t1, E t2){ + if(this.f==null){ + return ((Comparable)t1).compareTo(t2); + }else{ + return this.f.compare(t1,t2); + } + } + public Nodo padre(Nodo nodo){ + Nodo raizTmp = this.getRoot(); + Stack > pila = new Stack >(); + pila.push(raizTmp); + while(raizTmp.getRight()!=null || raizTmp.getLeft()!=null){ + if(this.compararDato(nodo.getData(), raizTmp.getData())>0){ + if(raizTmp.getRight()!=null){ + raizTmp = raizTmp.getRight(); + } + } + else if(this.compararDato(nodo.getData(), raizTmp.getData())<0){ + if(raizTmp.getLeft()!=null){ + raizTmp = raizTmp.getLeft(); + } + } + if(this.compararDato(nodo.getData(), raizTmp.getData())==0){ + return pila.pop(); + } + + pila.push(raizTmp); + } + return pila.pop(); + } + public int size(){ + return this.preOrden1().size(); + } + private List preOrden1(){ + List lista = new ArrayList(); + Nodo nodo = this.getRoot(); + Stack> pila = new Stack>(); + + while((nodo!=null && nodo.getData()!=null) || !pila.empty()){ + if(nodo!=null){ + lista.add(nodo.getData()); + pila.push(nodo); + nodo = nodo.getLeft(); + }else{ + nodo = pila.pop(); + nodo = nodo.getRight(); + } + } + + return lista; + } + public int equilibrado(Nodo n){ + int hIzq = 0; + int hDer = 0; + + if(n==null){ + return 0; + } + + hIzq = equilibrado(n.getLeft()); + + if(hIzq < 0){ + return hIzq; + } + + hDer = equilibrado(n.getRight()); + + if(hDer <0){ + return hDer; + } + + //si no es equilibrado + if(Math.abs(hIzq - hDer)>1){ + return -1; + } + + //si el trozo de arbol es AVL devolvemos la altura + return Math.max(hIzq, hDer) + 1; + } + + private Nodo estructurar(Nodo nodo, int altIzq, int altDer){ + if(extraeFactorE(nodo)==2){ + if( extraeFactorE(nodo.getRight())==1 || extraeFactorE(nodo.getRight()) == 0){ + //nodo = rotacionSimpleIzquierda1(nodo); + nodo=rotacionSimpleIzquierda(nodo); + } + + else if(extraeFactorE(nodo.getRight())==-1){ + //nodo = rotacionCompuestaDerecha(nodo); + nodo=rotacionDobleDerecha(nodo); + } + } + else if(extraeFactorE(nodo)==-2){ + if(extraeFactorE(nodo.getLeft())==-1 || extraeFactorE(nodo.getRight())==0){ + //nodo = rotacionSimpleDerecha1(nodo); + nodo=rotacionSimpleDerecha(nodo); + } + + else if(extraeFactorE(nodo.getLeft())==1){ + //nodo = rotacionCompuestaIzquierda(nodo); + nodo=rotacionDobleIzquierda(nodo); + } + } + + return nodo; + } + /*public Nodo rotacionCompuestaIzquierda(Nodo nodo){ + Nodo nodoTmp = nodo; //57 + + nodoTmp = rotacionSimpleIzquierda1(nodoTmp.getLeft()); //param 42 | sale: 54 + + nodo.setLeft(nodoTmp); //param 54 + + nodoTmp = rotacionSimpleDerecha1(nodo); //param 54 | sale: 54 + + return nodoTmp; + } + + + public Nodo rotacionCompuestaDerecha(Nodo nodo){ + Nodo nodoTmp = nodo; + + nodoTmp = rotacionSimpleDerecha1(nodoTmp.getRight()); + + nodo.setRight(nodoTmp); + + nodoTmp= rotacionSimpleIzquierda1(nodo); + + return nodoTmp; + } + public Nodo rotacionSimpleIzquierda1(Nodo nodo){ + Nodo nodoTmp = nodo; + + nodo = nodoTmp.getRight(); //clone?? + nodoTmp.setRight(nodo.getLeft()); + + nodo.setLeft(nodoTmp); + + return nodo; + } + + + public Nodo rotacionSimpleDerecha1(Nodo nodo){ + Nodo nodoTmp = nodo; + nodo = nodoTmp.getLeft(); + + nodoTmp.setLeft(nodo.getRight()); + nodo.setRight(nodoTmp); + + return nodo; + } + */ + public int extraeFactorE(Nodo nodo){ + if(nodo!=null){ + return nodo.getFactorE(); + }else{ + return 0; + } + } +} diff --git a/src/tda/Nodo.java b/src/tda/Nodo.java new file mode 100644 index 0000000..052521c --- /dev/null +++ b/src/tda/Nodo.java @@ -0,0 +1,92 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package tda; + +/** + * + * @author kmmarin + * @param + */ +public class Nodo { + private E data; + private Nodo left; + private Nodo right; + /** + * Factor de equilibrio + */ + private int fe; + + public Nodo(E data) { + this.data = data; + left=right=null; + } + + public int getFe() { + return fe; + } + + public void setFe(int fe) { + this.fe = fe; + } + + public E getData() { + return data; + } + + public void setData(E data) { + this.data = data; + } + + public Nodo getLeft() { + return left; + } + + public void setLeft(Nodo left) { + this.left = left; + } + + public Nodo getRight() { + return right; + } + + public void setRight(Nodo right) { + this.right = right; + } + public int getAltura(){ + int hIzq = 0; + int hDer = 0; + + if(this.getData()==null){ + return 0; + } + + + if(this.getLeft()!=null){ + hIzq = this.getLeft().getAltura(); + }else{ + hIzq = 0; + } + + if(this.getRight()!=null){ + hDer = this.getRight().getAltura(); + }else{ + hDer = 0; + } + return Math.max(hIzq, hDer) + 1; + } + public int getFactorE(){ + int altDer = 0; + int altIzq = 0; + if(this.getRight()!=null){ + altDer = this.getRight().getAltura(); + } + if(this.getLeft()!=null){ + altIzq = this.getLeft().getAltura(); + } + return (altDer - altIzq); + } + +} diff --git a/test/tda/AVLTest.java b/test/tda/AVLTest.java new file mode 100644 index 0000000..1db2449 --- /dev/null +++ b/test/tda/AVLTest.java @@ -0,0 +1,400 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package tda; + +import javafx.scene.layout.Pane; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author ktiusk + */ +public class AVLTest { + + public AVLTest() { + } + + @BeforeClass + public static void setUpClass() { + } + + @AfterClass + public static void tearDownClass() { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getRoot method, of class AVL. + */ + @Test + public void testGetRoot() { + System.out.println("getRoot"); + AVL instance = null; + Nodo expResult = null; + Nodo result = instance.getRoot(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of setRoot method, of class AVL. + */ + @Test + public void testSetRoot() { + System.out.println("setRoot"); + AVL instance = null; + instance.setRoot(null); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of isEmpty method, of class AVL. + */ + @Test + public void testIsEmpty() { + System.out.println("isEmpty"); + AVL instance = null; + boolean expResult = false; + boolean result = instance.isEmpty(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of height method, of class AVL. + */ + @Test + public void testHeight() { + System.out.println("height"); + AVL instance = new AVL<>(Integer::compareTo); + instance.Insert(8); + instance.Insert(2); + int expResult = 2; + int result = instance.height(); + assertEquals(expResult, result); + if(result != expResult) + fail("The test case is a prototype."); + } + + /** + * Test of totalNodos method, of class AVL. + */ + @Test + public void testTotalNodos() { + System.out.println("totalNodos"); + AVL instance = new AVL<>(Integer::compareTo); + instance.Insert(8); + instance.Insert(2); + int expResult = 2; + int result = instance.totalNodos(); + assertEquals(expResult, result); + if(result != expResult) + fail("The test case is a prototype."); + } + + /** + * Test of contarHojas method, of class AVL. + */ + @Test + public void testContarHojas() { + System.out.println("contarHojas"); + AVL instance = new AVL<>(Integer::compareTo); + instance.Insert(8); + instance.Insert(2); + int expResult = 1; + int result = instance.contarHojas(); + assertEquals(expResult, result); + if(result != expResult) + fail("The test case is a prototype."); + } + + /** + * Test of add method, of class AVL. + */ + @Test + public void testAdd() { + System.out.println("add"); + Object element = null; + AVL instance = null; + boolean expResult = false; + boolean result = instance.add(element); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of Insert method, of class AVL. + */ + @Test + public void testInsert() { + System.out.println("Insert"); + Nodo element = null; + AVL instance = new AVL<>(Integer::compareTo); + instance.Insert(8); + instance.Insert(2); + boolean expResult = false; + boolean result = instance.Insert(element); + assertFalse(result); + // TODO review the generated test code and remove the default call to fail. + if(result != expResult) + fail("The test case is a prototype."); + } + + /** + * Test of deleteNode method, of class AVL. + */ + @Test + public void testDeleteNode() { + System.out.println("deleteNode"); + Object element = null; + AVL instance = null; + boolean expResult = false; + boolean result = instance.delete(element); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of esDegenerado method, of class AVL. + */ + @Test + public void testEsDegenerado() { + System.out.println("esDegenerado"); + AVL instance = null; + boolean expResult = false; + boolean result = instance.esDegenerado(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of calcularCarga method, of class AVL. + */ + @Test + public void testCalcularCarga() { + System.out.println("calcularCarga"); + AVL instance = new AVL<>(Integer::compareTo); + instance.Insert(8); + instance.Insert(2); + int expResult = -1; + int result = instance.calcularCarga(); + assertEquals(expResult, result); + if(result != expResult) + fail("The test case is a prototype."); + } + + /** + * Test of rotacionSimpleIzquierda method, of class AVL. + */ + @Test + public void testRotacionSimpleIzquierda() { + System.out.println("rotacionSimpleIzquierda"); + AVL instance = null; + Nodo expResult = null; + Nodo result = instance.rotacionSimpleIzquierda(null); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of rotacionSimpleDerecha method, of class AVL. + */ + @Test + public void testRotacionSimpleDerecha() { + System.out.println("rotacionSimpleDerecha"); + AVL instance = null; + Nodo expResult = null; + Nodo result = instance.rotacionSimpleDerecha(null); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of rotacionDobleIzquierda method, of class AVL. + */ + @Test + public void testRotacionDobleIzquierda() { + System.out.println("rotacionDobleIzquierda"); + AVL instance = null; + Nodo expResult = null; + Nodo result = instance.rotacionDobleIzquierda(null); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of rotacionDobleDerecha method, of class AVL. + */ + @Test + public void testRotacionDobleDerecha() { + System.out.println("rotacionDobleDerecha"); + AVL instance = null; + Nodo expResult = null; + Nodo result = instance.rotacionDobleDerecha(null); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of max method, of class AVL. + */ + @Test + public void testMax() { + System.out.println("max"); + AVL instance = null; + Object expResult = null; + Object result = instance.max(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of min method, of class AVL. + */ + @Test + public void testMin() { + System.out.println("min"); + AVL instance = null; + Object expResult = null; + Object result = instance.min(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of contains method, of class AVL. + */ + @Test + public void testContains() { + System.out.println("contains"); + Object element = null; + AVL instance = null; + boolean expResult = false; + boolean result = instance.contains(element); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of posOrde method, of class AVL. + */ + @Test + public void testPosOrde() { + System.out.println("posOrde"); + AVL instance = null; + instance.posOrde(); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of preOrden method, of class AVL. + */ + @Test + public void testPreOrden() { + System.out.println("preOrden"); + AVL instance = null; + instance.preOrden(); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of enOrden method, of class AVL. + */ + @Test + public void testEnOrden() { + System.out.println("enOrden"); + AVL instance = null; + instance.enOrden(); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of nivel method, of class AVL. + */ + @Test + public void testNivel() { + System.out.println("nivel"); + Object element = null; + AVL instance = null; + int expResult = 0; + int result = instance.nivel(element); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of equals method, of class AVL. + */ + @Test + public void testEquals() { + System.out.println("equals"); + Object obj = null; + AVL instance = null; + boolean expResult = false; + boolean result = instance.equals(obj); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of hashCode method, of class AVL. + */ + @Test + public void testHashCode() { + System.out.println("hashCode"); + AVL instance = null; + int expResult = 0; + int result = instance.hashCode(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of mostrarArbol method, of class AVL. + */ + @Test + public void testMostrarArbol() { + System.out.println("mostrarArbol"); + AVL instance = null; + Pane expResult = null; + Pane result = instance.mostrarArbol(); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + +}