Explain why timing the sorting program is not a good method to measure the efficiency of the program.
Timing a sorting program is not a good way to measure the efficiency of the program. This is because various sorting algorithms work differently, based on the arrangement of values of the data.
e.g. The time complexity for quick sort in a general case is O(nlog n), but if the array is already sorted in ascending or descending order, or all the elements of the array are same, then this complexity becomes O(n^2). If insertion sort is applied on a sorted array, then the complexity is O(n). Thus, we can see how the sorting algorithm performance is highly data dependent. Hence, timing the sorting program is not the best way to measure the efficiency of the program.
Get Answers For Free
Most questions answered within 1 hours.