
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
Edition 8ISBN: 978-1285867410
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
Edition 8ISBN: 978-1285867410 Exercise 3
Using a Bubble Sort
int numbers[] = {432, -5, 54, -10, 36, 9, 65, 21, 24};const int NUM_ITEMS = 9;int j, k, temp;int numPasses = 0, numCompares = 0, numSwaps = 0;for(j = 0; j numbers[k+1]){numSwaps++;temp = numbers[k+1];numbers[k+1] = numbers[k];numbers[k] = temp;}}}
Do the variables named numPasses, numCompares, and numSwaps accurately keep track of the number of passes, compares, and swaps made in this bubble sort? Explain your answer.
int numbers[] = {432, -5, 54, -10, 36, 9, 65, 21, 24};const int NUM_ITEMS = 9;int j, k, temp;int numPasses = 0, numCompares = 0, numSwaps = 0;for(j = 0; j numbers[k+1]){numSwaps++;temp = numbers[k+1];numbers[k+1] = numbers[k];numbers[k] = temp;}}}
Do the variables named numPasses, numCompares, and numSwaps accurately keep track of the number of passes, compares, and swaps made in this bubble sort? Explain your answer.
Explanation
Values of variables:
, the given cod...
C++ Programs to Accompany Programming Logic and Design 8th Edition by Jo Ann Smith
Why don’t you like this exercise?
Other Minimum 8 character and maximum 255 character
Character 255