Question: PROBLEM STATEMENT: Write a program that will initialize an array, sort the array into ascending order, print the ascending, and original lists. CODE: The program






PROBLEM STATEMENT: Write a program that will initialize an array, sort the array into ascending order, print the ascending, and original lists. CODE: The program must not change the original array or create any other integer arrays. The solution requires an array of pointers to the array of integers. The pointers will be ordered according to the sequence of the values to which they refer. This array can then be processed from low to high or high to low for the ascending and descending lists respectively. Use any sort method form cs 121 that you learned: selection, insertion or bubble sort start with/use the provided cs 1321ab2_driver.cpp - (must be used) Complete the implementation for the given functions. Create the appropriate functions Make sure to complete the function comment headings. Run the program for the following: 26,14,57,33,41,60,19 The program will sort the array into ascending order. It will print the ascending and original lists. Run the program a second time for the following: 14 57 19 60 41 26 33 -34, -666, 666 18 Explorer Toolbox 19 20 21 #include using std::cin; using std::cout; using std::cerr; using std::endl; #include using std::bad_alloc; #include 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #define int_array 1 #define pointer2int_array 2 // Prototype declarations int getSize(); void* getArray( int &howMuch, int typeof ); 43 void populateArray( int num_of, int* ptr ); 44 45 46 42 47 20 48 10 49 ro 50 51 52 53 54 55 56 57 58 59 prototypes for swap function your sort function a function called printSortedArray which will print the sorted pointer array [*/ -- main -- II int main() { 100 % it CTZ - C/. No issues found Ln: 100 Ch: 1 SPC LF lorer Toolbox Elint main() { int SIZE = getSize(); int" dataArray = ( int*) getArray (SIZE, int_array ); int** pointerArray = ( int**)getArray (SIZE, pointerzint_array ); /* TODO add code here, call the appropriate functions */ // using a for loop, print the dataArray here delete [] dataArray; delete [] pointerArray; cout > howMuch; return howMuch; } 100 101 102 103 10 104 105 106 107 108 109 110 111 112 113 114 115 116 117 *** Function Name: Purpose: getArray dynamically allocates either an array of ints or an array of int pointers 118 Input Parameters: an int howMuch - the size of array to allocate an int typeof indicating the type of array to allocate Output parameters: none Return value: returns a pointer to an int array or an array of int pointers ***** *****/ 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 void* getArray( int ShowMuch, int typeof ) { try { switch (typeof) { case int_array: { int* p = new int [ howMuch ]; return( p ); } ****/ Explorer Toolbox void* getArray( int ShowMuch, int typeof) { - try { switch (typeof) { case int_array: { int* p = new int [ howMuch ]; return( p ); } 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 12 156 157 13 158 130 159 13 160 200 161 10 162 202 163 102 164 165 166 case pointer2int_array: { int** p = new int* [ howMuch ]; return( p ); } default: { cerr