Analisis Kompleksitas Waktu Eksekusi Algoritma Insertion Sort dan Selection Sort pada Berbagai Skenario Distribusi Data

Authors

  • Revani Zahra Afifah UIN K.H. Abdurrahman Wahid Pekalongan
  • Dina Nur Vidiana UIN K.H. Abdurrahman Wahid Pekalongan
  • Rizki Amalia UIN K.H. Abdurrahman Wahid Pekalongan
  • Cahya Putri Jelita UIN K.H. Abdurrahman Wahid Pekalongan
  • Imam Prayogo Pujiono UIN K.H. Abdurrahman Wahid Pekalongan

DOI:

https://doi.org/10.24252/shift.v6i2.294

Keywords:

Data Distribution, Insertion Sort, Python, Selection Sort

Abstract

The efficiency of sorting algorithms cannot be understood through theoretical analysis alone, as it depends heavily on interpreter execution in modern computing environments. Although Insertion Sort and Selection Sort share the same theoretical complexity of O(n²), their empirical performance diverges significantly due to initial data characteristics and memory allocation mechanisms. This study evaluates the interaction between data distribution and the execution overhead of the CPython interpreter on both algorithms. Experiments were conducted in an isolated Google Colab environment using a high-resolution timer on datasets ranging from [n_min] to [n_max] numerical elements, replicated over 10 independent iterations across three distribution scenarios: random, ascending, and descending. Quantitative analysis shows that the O(n²) label does not apply uniformly in practice. At [n_max], Insertion Sort reached its highest efficiency at 1.24 ms in the ascending case but collapsed drastically to 3,842.60 ms in the descending case. Conversely, Selection Sort showed rigid latency, remaining within 1,950–2,150 ms across all scenarios and gaining no advantage from pre-sorted data. This extreme disparity in the worst case does not stem purely from algorithmic computation but from the heavy overhead of reference counting and Python’s dynamic memory management when Insertion Sort performs massive index shifts (memory writes), whereas Selection Sort minimizes memory mutations. The findings establish a quantitative threshold recommending that fundamental sorting algorithms relying on intensive memory swaps and shifts be avoided in standard Python interpreters for datasets exceeding [n_threshold] elements.

Downloads

Download data is not yet available.

References

[1] M. I. Ali, R. D. Fardiarsyah, L. Shodik, F. Z. D. Kinanti, dan I. P. Pujiono, "Analisis Komparat-if Efisiensi Memori dan Waktu Komputasi pada 8 Algoritma Sorting menggunakan C++," LogicLink: Journal of Artificial Intelligence and Multimedia in Informatics, vol. 2, no. 1, hal. 1-17, 2025.

[2] I. P. Pujiono, E. H. Rachmawanto, dan N. A. S. Winarsih, "Array Sorting Algorithm vs Algo-ritma Pengurutan Tradisional: Analisis Efisiensi Memori dan Waktu," Jurnal Manajemen Informatika (JAMIKA), vol. 15, no. 1, hal. 47-59, 2025.

[3] H. Y. Tumanggor, R. M. F. Lubis, M. Sianturi, dan R. G. Purba, "Metode Algoritma Bubble Sort, Algoritma Merge Sort Dan Algoitma Quick Sort Dalam Pengujian Perbandingan Pros-es," JUTISAL (Jurnal Teknik Informatika Komputer Universal), vol. 2, no. 2, hal. 1-10, 2022.

[4] Y. A. Sandria, M. R. A. Nurhayoto, L. Ramadhani, R. S. Harefa, dan A. Syahputra, "Penerapan Algoritma Selection Sort untuk Melakukan Pengurutan Data dalam Bahasa Pemrograman PHP," Hello World Jurnal Ilmu Komputer, vol. 1, no. 4, hal. 190-194, 2022.

[5] P. D. Setyorini, L. T. Azzahro, R. A. Yuniar, dan I. P. Pujiono, "Pengembangan Alat Bantu Pembelajaran Sorting Algorithm Berbasis Visual Console C++," Jurnal Riset dan Aplikasi Mahasiswa Informatika (JRAMI), vol. 6, no. 3, hal. 685-694, 2025.

[6] P. Rahayuningsih, "Analisis Perbandingan Kompleksitas Algoritma Pengurutan Nilai (Sort-ing)," Jurnal Evolusi, vol. 4, no. 2, hal. 64-75, 2016.

[7] R. Putra, dkk., "Analisis Kinerja Algoritma Bubble Sort, Selection Sort, dan Insertion Sort Menggunakan Python pada Data Mahasiswa," JIPTI (Jurnal Ilmiah Penelitian Teknologi In-formasi), vol. 6, no. 2, hal. 1-8, 2025.

[8] A. H. Saptadi dan D. W. Sari, "Analisis Algoritma Insertion Sort, Merge Sort Dan Implemen-tasinya Dalam Bahasa Pemrograman C++," Jurnal INFOTEL, vol. 4, no. 2, hal. 10-17, 2012.

[9] S. A. Saputro dan F. N. Khasanah, "Teknik Selection Sort dan Insertion Sort dalam Penguru-tan Data," Jurnal RESTI (Rekayasa Sistem dan Teknologi Informasi), vol. 2, no. 1, hal. 15-20, 2018.

[10] D. R. Poetra, "Performa Algoritma Bubble Sort dan Quick Sort pada Framework Flutter dan Dart SDK," JATISI (Jurnal Teknik Informatika dan Sistem Informasi), vol. 9, no. 2, hal. 806-816, 2022.

[11] M. A. P. Siregar, dkk., "Analisis Kebutuhan Waktu Algoritma Insertion Sort, Merge Sort, dan Quick Sort dengan Kompleksitas Waktu," Jurnal Informatika, vol. 5, no. 1, hal. 1-8, 2018.

[12] I. P. Pujiono, M. R. Kamal, A. Prayogi, C. A. Sari, dan R. M. Ikhsanuddin, “Algoritma Count-ing Sort vs Algoritma Pengurutan Modern: Analisis Efisiensi Memori dan Waktu Kom-putasi,” Jurnal Informatika dan Teknik Elektro Terapan, vol. 13, no. 3, 2025, doi: 10.23960/jitet.v13i3.6657.

[13] S. N. Fatmaluna, N. G. Aulia, A. Rahma, S. Aulia, dan P. Pujiono, “Journal of Artificial Intel-ligence and Engineering Applications Comparison of Memory Efficiency and Computation Time of Bubble Sort, Insertion Sort, and Intro Sort Algorithms Using the C++ Programming Language,” 2026. [Online]. Available: https://ioinformatic.org/

[14] S. Zahwa, N. D. Amelia, R. Nafila, R. A. Putri, dan P. Pujiono, “Jurnal Restikom: Riset Teknik Informatika dan Komputer Perbandingan Efisiensi Memori dan Waktu Komputasi pada Al-goritma Rekursif dan Iteratif dalam Operasi Pengurutan di C++,” vol. 7, no. 1, hal. 123–136, 2025. [Online]. Available: https://restikom.nusaputra.ac.id

[15] T. Carneiro, R. V. M. Da Nobrega, T. Nepomuceno, G. Bin Bian, V. H. C. De Albuquerque, dan P. P. R. Filho, “Performance Analysis of Google Colaboratory as a Tool for Accelerating Deep Learning Applications,” IEEE Access, vol. 6, hal. 61677–61685, 2018, doi: 10.1109/ACCESS.2018.2874767.

[16] W. Mckinney, “Data Structures for Statistical Computing in Python,” 2010.

[17] M. Li, “Balancing Performance Trade-offs in Modern Sorting Methodologies,” 2024.

[18] J. Golonka dan F. Krużel, “Empirical Evaluation of Unoptimized Sorting Algorithms on 8-Bit AVR Arduino Microcontrollers,” Sensors, vol. 26, no. 1, 2026, doi: 10.3390/s26010214.

[19] N. A. R. S. Nasution, M. N. A. Surbakti, dan I. P. Sari, "Analisis Kompleksitas Diantara Algo-ritma Insertion Sort dan Selection Sort dan Diimplemntasikan dengan Bahasa Pemo-graman Java," InfoTekJar: Jurnal Nasional Informatika dan Teknologi Jaringan, vol. 8, no. 1, hal. 6-9, 2023, doi: 10.30743/infotekjar.v8i1.9641.

[20] A. Kusumaningrum, "Perbandingan Kecepatan Antara Selection Sort, Insertion Sort, dan Bubble Sort," Jurnal Teknomatika, vol. 6, no. 2, hal. 1-8, 2013.

[21] E. Alexander, "I Implemented Every Sorting Algorithm in Python — The Results Nobody Talks About (Benchmarked on CPython)," Python Sorting Benchmarks, 2025

[22] D. Grigorov, "Why Performance Matters in Python Development," JetBrains Engineering Blog, 2025.

[23] M. A. Ala'Anzy, Z. Mazhit, and A. F. Ala'Anzy, "Comparative Analysis of Sorting Algorithms: A Review," 2024 11th International Conference on Soft Computing & Machine Intelligence (ISCMI), pp. 88-100, 2024.

[24] A. Zade, V. Mandloi, "Bilateral Selection Sort," International Journal for Research in Ap-plied Science & Engineering Technology (IJRASET), vol. 8, no. 7, pp. 230-236, 2020

[25] J. Bodnar, "Python time.perf_counter() for Microbenchmarking," ZetCode Documenta-tion, 2023

Downloads

Published

06/30/2026

How to Cite

[1]
R. Z. Afifah, D. N. Vidiana, R. Amalia, C. P. Jelita, and I. P. Pujiono, “Analisis Kompleksitas Waktu Eksekusi Algoritma Insertion Sort dan Selection Sort pada Berbagai Skenario Distribusi Data”, Journal Software, Hardware and Information Technology (SHIFT), vol. 6, no. 2, pp. 168–177, Jun. 2026, doi: 10.24252/shift.v6i2.294.