Menu

(Solved) : Part 1 Implement Two Swap Methods Covered Lecture 10 Svapi Int X Int Y Svap2 Int Px Int Py Q26756575 . . .

Part 1. Implement the two swap methods we covered in Lecture 10 svapi (int x, int y svap2 (int px, int py) and, call them from your main function as int a-5, b-9 printf(%d %d, a, b); svapi(a, b): //call by value printf(%d %d, a, b); suap2.; //call printf(%d %d, a, by reference b); Part 2. Now implement a function void bubblesort int AD, int size) that will sort the array A using bubblesort. You MUST call your swap2 method from Part1 in your bubblesort function. Test bubblesort by calling from main) and printing array contents before and after the call to bubblesort Part 3. Recall Slide 41 from Lecturel0. Run example fig07 20.cpp under Lecture10 code posted on our piazza course site. Study the code. Make sure you understand that bPtr is ㏂ int * pointing to the first element of array b. Part 4. Fill in the following table based on the code fragment below. Assume that variable i is stored at memory address 112 Assume that cPtr is a variable stored at address 104, and the Array is a char array stored starting at address 116. (i) Do this first on paper based on the given addresses. ii) Now, implement this and print the given expressions in the table to check your table. (Addresses will be different of course.) (ii) Repeat the same exercise by changing theArray to an int array and changing cPtr to an int. char theArray-Hello World char cPtr theArray; int i-4;media%2F33d%2F33dd277a-7104-4b08-8946-00Part 1. Implement the two swap methods we covered in Lecture 10 svapi (int x, int y svap2 (int px, int py) and, call them from your main function as int a-5, b-9 printf(“%d %d”, a, b); svapi(a, b): //call by value printf(“%d %d”, a, b); suap2.; //call printf(“%d %d”, a, by reference b); Part 2. Now implement a function void bubblesort int AD, int size) that will sort the array A using bubblesort. You MUST call your swap2 method from Part1 in your bubblesort function. Test bubblesort by calling from main) and printing array contents before and after the call to bubblesort Part 3. Recall Slide 41 from Lecturel0. Run example fig07 20.cpp under Lecture10 code posted on our piazza course site. Study the code. Make sure you understand that bPtr is ㏂ int * pointing to the first element of array b. Part 4. Fill in the following table based on the code fragment below. Assume that variable i is stored at memory address 112 Assume that cPtr is a variable stored at address 104, and the Array is a char array stored starting at address 116. (i) Do this first on paper based on the given addresses. ii) Now, implement this and print the given expressions in the table to check your table. (Addresses will be different of course.) (ii) Repeat the same exercise by changing theArray to an int array and changing cPtr to an int. char theArray-“Hello World char cPtr theArray; int i-4; Show transcribed image text

Expert Answer


Answer to Part 1 Implement Two Swap Methods Covered Lecture 10 Svapi Int X Int Y Svap2 Int Px Int Py Q26756575 . . .

OR