Expert
Algorithm Optimization and Big-O Analysis
Analyze algorithmic inefficiency and optimize for time and space complexity.
📝 Nội dung Prompt
Analyze the following inefficient sorting algorithm. Determine its current time and space complexity using Big-O notation. Identify the specific bottlenecks causing the inefficiency. Rewrite the algorithm to optimize performance, aiming for O(n log n) time complexity in the average case. Explain the choice of the new algorithm and provide a comparison of performance characteristics between the original and optimized versions, including best and worst-case scenarios.