Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program in C language. Please ignore the pseudocode and don't ignore the function requirements in the file like swap. The values below are the input
Program in C language. Please ignore the pseudocode and don't ignore the function requirements in the file like swap.
The values below are the input values for this assignment (HW2 array), the values should be copied into an integer array of size 150. Thank you.
71, 1899, 272, 1694, 1697, 296, 722, 12, 2726, 1899, 1374, 1541, 1923, 1904, 1083, 1462, 2981, 1929, 304, 2550, 1059, 1860, 1963, 516, 647, 1607, 590, 157, 2351, 753, 2455, 349, 79, 1634, 368, 1992, 2401, 357, 1478, 1601, 239, 365, 2453, 2283, 2432, 1223, 2739, 2487, 2714, 1391, 1972, 2805, 1504, 413, 1647, 2750, 44, 64, 934, 1008, 1429, 1427, 315, 2499, 1620, 1816, 2441, 2557, 2188, 531, 1514, 2825, 449, 265, 2064, 1022, 34, 1864, 1861, 1516, 1465, 2327, 398, 2769, 563, 194, 429, 942, 1795, 223, 2406, 780, 780, 61, 133, 195, 495, 1774, 1934, 2171, 433, 1417, 292, 324, 2929, 1597, 1470, 764, 593, 891, 679, 47, 1778, 2532, 1862, 2636, 549, 2923, 2270, 1101, 1607, 2395, 726, 1111, 892, 1988, 555, 379, 224, 298, 1660, 2203, 2385, 2159, 2574, 705, 2513, 1755, 313, 173, 148, 2449, 259, 1006, 1221, 2259, 2020, 1484, 2717, 2400Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make a copy of one array into another, and then to sort the second array. This would allow us to view the data both in the original order and in the sorted order. This might be fine in many cases, but if the data set is large and memory limited (say, perhaps, in an embedded system), this solution might not be practicable. A more elegant solution is to sort the array indirectly, i.e., by using pointers. With this technique we wouldn't change the positions of the actual data items in the array, we would only change the values of the pointers that point into the array. Nevertheless, when this type of sorting is performed, we still will be able to access the data both in its original order, by using the original array, but also in sorted order, by using the array of pointers. Here are some diagrams that illustrate the idea
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started