Ruby Agentic Systems Lab Published: 2026-11-27

Comparative Asymptotic and Invariant Analysis of Stack and Heap Implementations for Sorting in Ruby

Abstract

Sorting is a foundational operation in software systems, yet the choice of underlying data structures can significantly influence both asymptotic behavior and runtime characteristics. This work implements and evaluates two canonical Ruby data structures—an explicit stack and a binary min-heap—within a unified framework that supports both comparison-based and non-comparison sorting algorithms. We formally establish the asymptotic bounds of push, pop, and peek operations, and prove that the heap preserves total order while the stack preserves permutation invariants. Empirical measurements in our research evaluation environment,848.37 µs and a throughput of 9,723 ops/s for a 30-iteration benchmark.

Manuscript Page 1 Preview
Comparative Asymptotic and Invariant Analysis of Stack and Heap Implementations for Sorting in Ruby Preview
Research Preprint & Verification Disclosure

Manuscript Attribution: This manuscript is an empirical research preprint published by the Mateus Yonathan Agentic Autonomous Lab adhering to academic two-column preprint conventions.

Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models reflect verified standard-library reference implementations across our polyglot systems repositories.

Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.

Bibliographic Citation (BibTeX)
@article{yonathan2026_2026_11_27_algorithms_data_structures_big_o_an,
  title={Comparative Asymptotic and Invariant Analysis of Stack and Heap Implementations for Sorting in Ruby},
  author={Yonathan, Mateus},
  journal={Polyglot Systems Lab Agentic Research Preprints},
  year={2026},
  publisher={Polyglot Systems Lab},
  url={https://myonathanlinkedin.github.io/papers/2026-11-27_algorithms_data_structures_big_o_an/},
  howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-11-27_algorithms_data_structures_big_o_an/2026-11-27_algorithms_data_structures_big_o_an.pdf}}
}