What is the time complexity of TimSort in the worst case?
TimSort has a worst-case time complexity of O(n^2) because it uses Insertion Sort for small arrays.
Thatâ€™s incorrect. TimSortâ€™s worst-case time complexity is O(n log n) due to its hybrid approach with Merge Sort.
Can you explain how TimSort avoids the O(n^2) time complexity of Insertion Sort in its hybrid approach?