# leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1 architecture

> Architecture diagram of the GitHub repository leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1
- Repository: https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1

## Overview

#### 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: [`src/main.cpp`](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/main.cpp) (Benchmark orchestrator), [`src/GestorDataset.cpp`](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/GestorDataset.cpp) (Dataset manager), [`src/ComparadorPalabras.cpp`](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/ComparadorPalabras.cpp) (Word comparator), [`src/OrdenamientoRapido.cpp`](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/OrdenamientoRapido.cpp) (QuickSort)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_build["Build"]
  node_makefile["Make build target<br/>build definition"]
  node_cmake["CMake build target<br/>build definition<br/>[CMakeLists.txt]"]
end

subgraph group_runtime["Benchmark Runtime"]
  node_main["Benchmark orchestrator<br/>C++ entry point<br/>[main.cpp]"]
  node_dataset["Dataset manager<br/>data and validation service<br/>[GestorDataset.cpp]"]
  node_timer["Performance meter<br/>timing service"]
  node_comparator{{"Word comparator<br/>ordering contract"}}
end

subgraph group_algorithms["Sorting Branches"]
  node_quick["QuickSort<br/>in-place vector sort"]
  node_utilities["General utilities<br/>shared utility"]
  node_heap["HeapSort<br/>in-place vector sort"]
  node_avl["AVL sorter<br/>balanced tree sort<br/>[ArbolAVL.cpp]"]
end

subgraph group_filesystem["Filesystem"]
  node_input["Word dataset<br/>runtime input<br/>[dataset.txt]"]
  node_outputs["Sorted outputs<br/>generated artifacts"]
  node_report["Performance report<br/>generated artifact"]
end

node_stdlib{{"C++17 standard library<br/>runtime dependency"}}

node_makefile -->|"builds"| node_main
node_cmake -->|"builds"| node_main
node_main -->|"loads, validates, saves"| node_dataset
node_input -->|"word input"| node_dataset
node_main -->|"times independent copy"| node_quick
node_main -->|"times independent copy"| node_heap
node_main -->|"times ingestion and traversal"| node_avl
node_main -->|"measures branches"| node_timer
node_quick -->|"orders with"| node_comparator
node_heap -->|"orders with"| node_comparator
node_avl -->|"orders with"| node_comparator
node_quick -->|"swaps via"| node_utilities
node_dataset -->|"validates under"| node_comparator
node_dataset -->|"writes sorted files"| node_outputs
node_main -->|"writes measurements"| node_report
node_main -.->|"uses"| node_stdlib
node_dataset -.->|"uses file I/O"| node_stdlib

click node_makefile "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/Makefile"
click node_cmake "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/CMakeLists.txt"
click node_main "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/main.cpp"
click node_dataset "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/GestorDataset.cpp"
click node_timer "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/MedidorRendimiento.cpp"
click node_comparator "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/ComparadorPalabras.cpp"
click node_quick "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/OrdenamientoRapido.cpp"
click node_utilities "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/include/UtilidadesGenerales.hpp"
click node_heap "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/MonticuloBinario.cpp"
click node_avl "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/ArbolAVL.cpp"
click node_input "https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/data/dataset.txt"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_makefile,node_cmake toneBlue
class node_main,node_dataset,node_timer,node_comparator toneAmber
class node_quick,node_utilities,node_heap,node_avl toneMint
class node_input,node_outputs,node_report toneRose
class node_stdlib toneNeutral
```

## Components

### Build

- [Make build target](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/Makefile): build definition · `Makefile`
- [CMake build target](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/CMakeLists.txt): build definition · `CMakeLists.txt`

### Benchmark Runtime

- [Benchmark orchestrator](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/main.cpp): C++ entry point · Sequences loading, copies, timing, validation, and persistence. · `src/main.cpp`
- [Dataset manager](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/GestorDataset.cpp): data and validation service · Loads words, validates ordering/equality, and writes results. · `src/GestorDataset.cpp`
- [Performance meter](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/MedidorRendimiento.cpp): timing service · Provides steady-clock timing and memory estimates. · `src/MedidorRendimiento.cpp`
- [Word comparator](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/ComparadorPalabras.cpp): ordering contract · Case-insensitive alphabetical comparison shared by all strategies. · `src/ComparadorPalabras.cpp`

### Sorting Branches

- [QuickSort](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/OrdenamientoRapido.cpp): in-place vector sort · Random-pivot Lomuto partitioning with bounded recursion depth. · `src/OrdenamientoRapido.cpp`
- [General utilities](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/include/UtilidadesGenerales.hpp): shared utility · Supplies shared swapping. · `include/UtilidadesGenerales.hpp`
- [HeapSort](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/MonticuloBinario.cpp): in-place vector sort · Implicit max heap with bottom-up construction and iterative sift-down. · `src/MonticuloBinario.cpp`
- [AVL sorter](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/src/ArbolAVL.cpp): balanced tree sort · Inserts into a height-tracked tree then emits in-order values. · `src/ArbolAVL.cpp`

### Filesystem

- [Word dataset](https://github.com/leoduarte-ops/practica-estructuras-de-datos-y-algoritmos-1/blob/main/data/dataset.txt): runtime input · Required repository-relative input file. · `data/dataset.txt`
- **Sorted outputs**: generated artifacts · QuickSort, HeapSort, and AVL result files.
- **Performance report**: generated artifact

### Other components

- **C++17 standard library**: runtime dependency · Vectors, strings, randomization, clocks, and file I/O.

## Connections

- 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
