• edited by
1,259 views
0 0 votes
Suppose we are comparing implementations of insetion sort and merge sort on the same machine. For inputs of size n, insertion sort runs in 8n^2 steps, while merge sort runs in 64nlgn steps. For which values of n does insertion sort beat merge sort?

1 Answer

0 0 votes
I know that Insertion sort is better as compared to Merge sort only for small set of Imputs . Here if i put n=2 then i get 32 steps for merge and 128 steps . SO here only Insertion has beat Merge sort . Continuing in this manner at n =43 i would get 14792 steps and 147933.806 steps in merge . After this the whole scenario changes Merge Sort wins ! So the answer for above will be from 2 to 42 right or just 42 ?
Position:
Show:

Related questions

2 2 votes
2 answers 2 answers
2.7k
2.7k views
Bikram asked Nov 26, 2016
2,696 views
Meena is working in an IT company as HR manager. She has a large list of potential candidates to be recruited which are all sorted by their names. But she found that due ...
1 1 vote
1 1 answer
147
147 views
GO Classes asked Aug 10
147 views
Mergesort recursively sorts the two halves of an array.After both recursive calls have finished, but before the merge operation, which statement must be true?The complete...
3 3 votes
2 2 answers
1.6k
1.6k views
GO Classes asked Feb 5, 2024
1,640 views
Consider the following array$: [32, 33, 5, 2, 14, -4, 22, 39, 34, -9].$ We apply a certain sorting algorithm and observe that the array has been modified to $[2, 5, 14, 3...