Question: #include // Swap the values of the integer variables pointed to by p1 and // p2. After the function returns, the variable pointed to by
| #include | |
| // Swap the values of the integer variables pointed to by p1 and | |
| // p2. After the function returns, the variable pointed to by p1 | |
| // should have the value once pointed to by p2, and vice-versa. | |
| // | |
| // You may use a temporary variable or do an XOR swap. | |
| void | |
| swap(int *p1, int *p2) | |
| { | |
| assert(p1 != 0); | |
| assert(p2 != 0); | |
| // TODO: Your code here. | |
| assert(0); | |
| } | |
| // bubble_sort implements the bubble sort algorithm. | |
| // https://en.wikipedia.org/wiki/Bubble_sort | |
| // It is given an integer array "arr" of "n" elements. | |
| // Upon return, the integer array should contain the sorted numbers | |
| // in increasing order. | |
| // You should use the previous swap function when implementing bubble_sort | |
| void | |
| bubble_sort(int *arr, int n) | |
| { | |
| // TODO: Your code here. | |
| assert(0); | |
| } |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
