Documentation Index
Fetch the complete documentation index at: https://mintlify.com/kenri89/PROYECTO_UTP_AED_1_1/llms.txt
Use this file to discover all available pages before exploring further.
ArbolEstudiantes in estructuras.ArbolEstudiantes implements a standard unbalanced Binary Search Tree. The BST key is the carnet field of each Estudiante object, and ordering is determined by Java’s String.compareTo(), which gives lexicographic (alphabetical) ordering across all carnet strings. Every node holds a direct reference to an Estudiante model object — there is no separate key/value split.
Internal Node Structure
The node class is a private static inner class invisible to callers. It stores a reference to theEstudiante payload and left/right child pointers.
Public API
insertar(Estudiante nuevo)
Recursive BST insert descending from
raiz. At each node the carnet of nuevo is compared with String.compareTo() — go left if negative, go right if positive, skip if equal (duplicate carnets are silently ignored). Average complexity is O(log n); worst case with sorted inserts is O(n).buscar(String carnet)
Recursive lookup that halves the search space at every node. Returns the matching
Estudiante or null if not found. Average complexity O(log n).actualizar(String carnet, String nuevoNombre, String nuevaCarrera)
Delegates to
buscar to locate the node, then mutates the nombre and carrera fields in-place. The carnet (BST key) is never changed. Returns true if found, false otherwise. Complexity O(log n).eliminar(String carnet)
Standard BST removal with in-order successor promotion for two-child nodes. Complexity O(log n) average. See the deletion algorithm section below for details.
inorden(Consumer<Estudiante> accion)
Left-root-right recursive traversal that visits every node exactly once in ascending carnet order. The caller provides a
Consumer<Estudiante> lambda — typically lista::add or a table-row builder. Complexity O(n).Deletion Algorithm
When the node to be deleted has two children, the algorithm finds the in-order successor — the node with the smallest carnet in the right subtree — copies itsEstudiante data into the current node, then recursively deletes the successor from the right subtree. This guarantees the BST property is preserved after every deletion.
Usage Example
The BST is unbalanced — repeated sequential inserts (e.g., carnets in strict ascending order) cause the tree to degenerate into a linear chain, degrading all operations to O(n). For the typical use case with randomly distributed carnets this effect is negligible, and self-balancing was deliberately excluded as out-of-scope for the course unit.