Question: Please Code In C + + Objectives: Comparison of Insertion short and Shell sort Shell sort is a highly efficient sorting algorithm and is based

Please Code In C++Objectives: Comparison of Insertion short and Shell sort
Shell sort is a highly efficient sorting algorithm and is based on Insertion sort algorithm.
Write a program to sort a random integer arrSample Output: Insertion and Shell sorts
***** Program to compare Shell sort and Insertion sort *****
Enter the number of elements to be sorted (0 to exit): 50
==================== TEST 1=========================
Test case with 50 elements:
58651501057723026897358784
3934885955017465315187413653
988929567436854168656691817617
6264365155
------------ Insertion sort ------------
- Number of comparisons: 500
- Number of items moves: 546
- Sorting time : 6400 nanoseconds
112557101517172629303436
363639414146505051535355565758
596264656566687374768184858787
8889899198
------------ Shell sort ------------
- Number of comparisons: 164
- Number of items moves: 246
- Sorting time : 5200 nanoseconds
112557101517172629303436
363639414146505051535355565758
596264656566687374768184858787
8889899198
Time performance of Shell sort over Insertion sort: 20.69%
------------------- New Test Case ----------------------
Enter the number of elements to be sorted (0 to exit): 100
==================== TEST 2=========================
Test case with 100 elements:
68425736866976889749455189056
18529651432992232856976324672
1645478286352175787822814814
695272382959459714843573242767
29678513755555968128963412232
70619716986457489942451635276
037513491905655640
------------ Insertion sort ------------
- Number of comparisons: 2449
- Number of items moves: 2542
- Sorting time : 30400 nanoseconds
0014556912141416171818
222223242427282829292932323435
363737384142434545464849515151
515252525254555555565656575759
596163636364646467686869697072
727376767678787878818486888989
90909192949697979798
------------ Shell sort ------------
- Number of comparisons: 514
- Number of items moves: 747
- Sorting time : 14200 nanoseconds
0014556912141416171818
222223242427282829292932323435
363737384142434545464849515151
515252525254555555565656575759
596163636364646467686869697072
727376767678787878818486888989
90909192949697979798
Time performance of Shell sort over Insertion sort: 72.65%
------------------- New Test Case ----------------------
Enter the number of elements to be sorted (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!