How leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1 works
Purpose and Execution
A C++17 command-line benchmark sorts the word dataset three ways, validates equivalence, and writes sorted outputs plus a performance report. The process is orchestrated by src/main.cpp; build targets are defined in Makefile and CMakeLists.txt. Runtime input is data/dataset.txt, resolved relative to the repository root.
Dataset and Shared Ordering Contract
GestorDataset loads words into vectors, persists result files, and verifies sortedness and cross-algorithm equality: include/GestorDataset.hpp, src/GestorDataset.cpp. All strategies depend on the same case-insensitive alphabetical comparison contract in include/ComparadorPalabras.hpp and src/ComparadorPalabras.cpp; this shared boundary is essential so benchmark outputs are semantically comparable.
QuickSort Pipeline
QuickSort operates in-place on an independent std::vector<std::string> copy of the input. include/OrdenamientoRapido.hpp and src/OrdenamientoRapido.cpp implement Lomuto partitioning with randomized pivots. It recurses into the smaller partition and iterates over the larger one, limiting stack depth while preserving the expected O(n log n) behavior. Shared swapping is supplied by include/UtilidadesGenerales.hpp.
HeapSort Pipeline
HeapSort also receives its own vector copy and sorts it in-place. include/MonticuloBinario.hpp and src/MonticuloBinario.cpp model a max binary heap implicitly within that vector: bottom-up heap construction, repeated root/end exchanges, and iterative sift-down produce ascending output. This is the deterministic worst-case O(n log n) branch, with O(1) auxiliary structure overhead.
AVL Pipeline
The AVL branch inserts input words into a dynamically allocated, height-tracked balanced search tree, then emits ordered values through in-order traversal. include/ArbolAVL.hpp and src/ArbolAVL.cpp encapsulate node ownership, insertion, single/double rotations, traversal, and recursive cleanup. Unlike the vector algorithms, this branch trades materially higher node memory for maintaining sorted searchable structure throughout ingestion.
Measurement, Validation, and Outputs
include/MedidorRendimiento.hpp and src/MedidorRendimiento.cpp provide steady-clock timing and sizeof-based memory estimates. main sequences load → duplicate inputs → time each algorithm → validate individual ordering and exact result equality → save artifacts. Generated outputs belong under resultados/, notably resultados/salida_quicksort.txt, resultados/salida_heapsort.txt, resultados/salida_arbol_avl.txt, and the performance report.
Runtime and External Boundaries
The executable is local-only: no network APIs, databases, UI, or cloud infrastructure are indicated. Material dependencies are the C++ standard library (vector, string, randomization, chrono, file I/O) and a C++17 compiler; the documented development compiler is g++ 13.3. The filesystem is the primary external boundary: missing or incorrectly located data/dataset.txt prevents normal execution, and resultados/ must be writable for artifact generation.
Main entry points: main.cpp Benchmark orchestrator · GestorDataset.cpp Dataset manager · ComparadorPalabras.cpp Word comparator · OrdenamientoRapido.cpp QuickSort
Components 14
Build
- Make build target
Makefile - CMake build target
CMakeLists.txt
Benchmark Runtime
- Benchmark orchestrator · Sequences loading, copies, timing, validation, and persistence.
src/main.cpp - Dataset manager · Loads words, validates ordering/equality, and writes results.
src/GestorDataset.cpp - Performance meter · Provides steady-clock timing and memory estimates.
src/MedidorRendimiento.cpp - Word comparator · Case-insensitive alphabetical comparison shared by all strategies.
src/ComparadorPalabras.cpp
Sorting Branches
- QuickSort · Random-pivot Lomuto partitioning with bounded recursion depth.
src/OrdenamientoRapido.cpp - General utilities · Supplies shared swapping.
include/UtilidadesGenerales.hpp - HeapSort · Implicit max heap with bottom-up construction and iterative sift-down.
src/MonticuloBinario.cpp - AVL sorter · Inserts into a height-tracked tree then emits in-order values.
src/ArbolAVL.cpp
Filesystem
- Word dataset · Required repository-relative input file.
data/dataset.txt - Sorted outputs · QuickSort, HeapSort, and AVL result files.
- Performance report
Other components
- C++17 standard library · Vectors, strings, randomization, clocks, and file I/O.
Connections 17
- Make build target → Benchmark orchestrator: builds
- CMake build target → Benchmark orchestrator: builds
- Benchmark orchestrator → Dataset manager: loads, validates, saves
- Word dataset → Dataset manager: word input
- Benchmark orchestrator → QuickSort: times independent copy
- Benchmark orchestrator → HeapSort: times independent copy
- Benchmark orchestrator → AVL sorter: times ingestion and traversal
- Benchmark orchestrator → Performance meter: measures branches
- QuickSort → Word comparator: orders with
- HeapSort → Word comparator: orders with
- AVL sorter → Word comparator: orders with
- QuickSort → General utilities: swaps via
- Dataset manager → Word comparator: validates under
- Dataset manager → Sorted outputs: writes sorted files
- Benchmark orchestrator → Performance report: writes measurements
- Benchmark orchestrator → C++17 standard library: uses
- Dataset manager → C++17 standard library: uses file I/O