International Journal of Academic Information Systems Research (IJAISR)

Title: Learning to Sort: A Machine Learning Approach to Algorithm Selection and Optimization.

Authors: Basheer Ali Ghazal, Abdullah Salam Alnkhala, Samy S. Abu-Naser

Volume: 10

Issue: 7

Pages: 8-22

Publication Date: 2026/07/28

Abstract:
Sorting is a fundamental operation in computer science and plays a critical role in numerous applications, including database management systems, search engines, operating systems, data analytics, and scientific computing. Conventional sorting algorithms, such as QuickSort, MergeSort, and InsertionSort, exhibit distinct performance characteristics that depend heavily on the size, distribution, and degree of order within the input data. Since these algorithms employ fixed execution strategies, they cannot dynamically adapt to varying input characteristics, often leading to suboptimal performance or worst-case computational complexity under unfavorable conditions. To address this limitation, this paper proposes a lightweight machine learning-based framework for intelligent sorting algorithm selection. The proposed approach formulates algorithm selection as a multi-class classification problem, where statistical metadata extracted from an input array-including array size, approximate sortedness, and data variance-are used to predict the most suitable sorting algorithm before execution. A Decision Tree classifier is selected due to its low computational overhead, interpretability, and fast inference capabilities, making it suitable for real-time algorithm routing. The classifier is trained offline using a synthetically generated dataset comprising 10,000 arrays with diverse sizes, distributions, and levels of sortedness, where optimal algorithm labels are assigned through empirical performance benchmarking. During runtime, the trained model analyzes the extracted features and dynamically routes each input to the predicted optimal sorting algorithm. Experimental evaluation on a validation dataset containing 1,000 arrays demonstrates that the proposed hybrid framework consistently achieves execution times comparable to the best-performing static algorithm while effectively avoiding performance degradation associated with unfavorable input patterns, particularly those affecting QuickSort. The additional computational overhead introduced by feature extraction and model inference remains minimal, making the framework practical for real-world applications. These findings demonstrate that integrating lightweight machine learning techniques with classical algorithm design enables adaptive, data-aware execution, improving computational efficiency without modifying the underlying sorting algorithms. The proposed framework provides a scalable and extensible foundation for intelligent algorithm selection in modern software systems and highlights the potential of machine learning to enhance traditional algorithm engineering.

Download Full Article (PDF)