For inputs of size n for which values โ€‹โ€‹of n do insert-sort sort sort sorting?

In Corman, Exercise 1.2-2 asks the following question about comparing insertion sort and merge sort implementations. For inputs of size n, sorting inputs are sorted in 8n ^ 2 steps, and merge sorting is performed in 64 n lg n steps; for which values โ€‹โ€‹of n insert sort sort sort sort sort?

Although I'm interested in the answer, I'm more interested in how to find the answer step by step (so that I can repeat the process of comparing any two given algorithms, if at all possible).

At first glance, this problem seems similar to what is breaking even in business calculus, a class I took over 5 years ago, but I'm not sure any help would be appreciated.

thanks





P / S If my tags are incorrect, this question is incorrectly classified or any other agreement is used, please limit the punishment to a minimum, as this is my first question.

+7
sorting algorithm time-complexity mergesort insertion-sort
source share
1 answer

Because you have to find when sorting sorting sorting sorting

8n^2<=64nlogn n^2<=8nlogn n<=8logn 

When solving n-8logn = 0 you get

 n = 43.411 

So, for n<=43 insertion sorting works better than merge sorting.

+18
source share

All Articles