Question: Pointers and Bubbles (A2) s Due Friday by 11:59pm Points 100 Overview C-style pointers are important to understand, because they live on in higher level

 Pointers and Bubbles (A2) s Due Friday by 11:59pm Points 100
Overview C-style pointers are important to understand, because they live on in
higher level languages. This lab will help you come to grip with

Pointers and Bubbles (A2) s Due Friday by 11:59pm Points 100 Overview C-style pointers are important to understand, because they live on in higher level languages. This lab will help you come to grip with pointers and how useful they can become The bubble sort is an easy-to-implement algorithm for sorting a group of elements. Here's the basic algorithm: for in list - 1 for sin list - 1 1 list ist 11 Swap ist) and list[d.1) ch nic & wort "SO Essentially, it looks through a list and checks each element against its neighbor. If an element is larger than the next element, the two elements should be swapped. One pass through the list is not sufficient to sort the entire list. The safest approach is to run the test in a pair of nested loops. One could argue that this is not absolutely necessary or efficient, but that will be the subject of another lab.) The interesting part of this process from our current perspective is the swap function. We need to give it two variables, and it needs to change the position of the values in those variables. When a function changes a single variable, we often simply have the function return a value and then we re-assign that value to the variable in question, but functions can typically only return a single value. How do you handle a case like swap where you want to change the values of two variables at once? The solution is to pass pointers to the variables in question. Your Task sement ent) ter Implement a simple bubble sort algorithm. Please begin with the following code snippet: /bubble.c / famous bubble sort 1/implement the Swap algorithm with pointers Sinclude #define MAX 9 1/function prototypes vold printvalues(); void sort(); void swap(int", int); int valuesli - 17, 3, 5, 4, 6, 1, 2, 3, 5): int saint printf("before"); printValues(): sort(): printf("After: "); print Values return(0) 1 // end main Please note the following things about the code snippet: I've provided all the function prototypes you need. You will not need to change these prototypes (nor should you.) The main() function is complete. There is no need to modify the main() function. You will need to build the other necessary functions The prototypes should give you a good hint what the functions should be and how they should be written. The sorti) function should follow the algorithm described above The swap function must use pointers. There are ways to make this program work without pointers, but the purpose of this project is to have a real-life example of pointer work. See the output below for an indication how the printValues() function should be written This program should be written in C. NOT C++. I want to be certain you can get around the language if you need Please use pointers, not references or other tricks. That's what this project is about Output to The output of the program should look something like this Output The output of the program should look something like this: Before: 17 3 9451 2851 (37 94612851 [3 74 9612851 [3 74 691285) (3 746 19.2651 13 7.4612985] (3 7.4 6.12 895) (3.7.461 285.91 (3 47 51 285.91 [3 4 6 7 12 859) 13.4.61728591 [3.45 127 85.91 (3 461 275091 (3 416 275 891 13 41 2675191 341265789) (3 1 4 2 65.781 3124657891 3 12 4 5 6 7 8 9 1 1) 245.6789 1234567891 Arteri 1234567891 Note that I printed the current status of the array after every swap. Also note there is a single array: The actual values are moving around in the original data structure

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 Databases Questions!