The selection of linear data structures directly impacts memory efficiency and software performance. This study conducts a profound comparative analysis between arrays and linked lists using a quantitative experimental approach. Benchmarking was performed across sequential access, random access, insertion, and deletion scenarios using C++ and Python with dataset sizes from 103 to 107 elements. Memory consumption was tracked via Valgrind Massif and the tracemalloc library. In C++, arrays consistently outperform linked lists in sequential access with a 3.2× speedup on 106 elements due to optimal CPU cache locality. Conversely, for middle insertions, linked lists show a dramatic advantage with a constant time of ~50ns, compared to 2.3ms for arrays (46,000× slower). Regarding memory for primitive data, singly linked lists incur a 200% pointer overhead and doubly linked lists 400% on 64-bit systems. This research concludes that arrays serve as the best default for intensive computation, while linked lists are recommended for dynamic data manipulation.
Copyrights © 2026