A Complete Guide to Programming in C++ part 73. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | SOLUTIONS 699 Exercise 3 --------------------------------------------------------- Compares the performances of sorting algorithms quick sort and selection sort For this purpose two identical arrays are dynamically generated and initialized with random numbers. The times needed for sorting are displayed. --------------------------------------------------------- include iostream include iomanip include cstdlib include ctime using namespace std void isort int v int lenv For qsort extern C int intcmp const void const void main unsigned int i size int numbers1 numbers2 long timel time2 cout n The performance of the sorting algorithms n quick sort and selection sort n is being compared. n n nHow many numbers are to be sorted cin size numbersl new int size numbers2 new int size cout nThere are size random numbers to be generated. n srand unsigned time NULL Initialize the random number generator. for i 0 i size i numbers1 i numbers2 i rand Random numbers cout nSorting starts Please wait. n time time1 Length of time for quick sort. qsort numbers1 size sizeof int intcmp time time2 cout nTime taken by the quick sort algorithm time2 - timel seconds. n 700 CHAPTER 30 MORE ABOUT POINTERS cout nI am sorting again. Please wait n time time1 Length of time isort numbers2 size for selection sort time time2 cout nTime taken by the insertion sort algorithm time2 - timel seconds. n nOutput sorted numbers y n n n char c cin c if c Y c y for i 0 i size i cout setw 12 numbers1 i cout endl return 0 extern C int intcmp const void a const void b return int a - int b sorts an array of int values using the selection sort algorithm. int len minp isort void isort int a register int b int last help last a len - 1 for a last a minp a for b a 1 b if b minp minp b Sort the array a of length len in ascending order Points to the last element Search for the smallest element starting at a. minp points to the current smallest array element. last b Search for the minimum. help a a minp minp .