Question: If you sort an array, you must physically move/swap the data from its original location to other location. Small arrays not a real problem, the
If you sort an array, you must physically "move/swap" the data from its original location to other location. Small arrays not a real problem, the larger the number of items, the more I/O verhead involved. What if we need to keep that array in its original order? Creating duplicate arrays is not a solution. How about using memory pointers? What if we use a "shadow array of pointers to each index location in the original array"? The pointer addresses are swapped instead of the actual data values. Load an integer array (called it "mumbers") of size 15 with random integer values ranging from 1 to 100 Create two additional arrays of pointers, aim the array index pointers to the integer array Pass the first array of pointers to a sort function to "sort ascending order the pointer values based on the value that these pointers are "pointing" to in the "numbers" array. The pointer values will be swapped within the pointer array Pass the second array of pointers to a function to sort descending order" the pointer values based on the value that these pointers are "pointing to in the numbers" array The pointer values will be swapped within the pointer array Display the contents of the numbers array Display the numeric values that the ascending pointer array and the descending pointer array are pointing" at in the numbers array You will need to code an ascending and descending sort (simplest is a "bubble") Default
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
