Advanced
Algorithm Optimization and Analysis
Analyze inefficient sorting code and optimize it for specific data characteristics.
📝 Prompt Inhoud
Review the following Bubble Sort implementation. Analyze its time and space complexity (Big O). Then, rewrite the algorithm using a more efficient sorting method appropriate for a large dataset with nearly sorted characteristics. Explain the choice of the new algorithm and provide a step-by-step comparison of performance between the old and new implementations.