Discover the answers you need at Westonci.ca, where experts provide clear and concise information on various topics. Explore a wealth of knowledge from professionals across various disciplines on our comprehensive Q&A platform. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

(2) Declare and implement a function called sortSwapCount that passes three parameters, the array, the size and the reference of proportion, and returns the count. The function declaration is int sortSwapCount (int data[], int size, double& proportion) The function sorts the integers in data[] in ascending order using the bubble sort method. The purpose is to count or determine the number of exchanges (swaps) made by the bubble sort algorithm. (0) (ii) The expected number of sorting swaps (expectedSwapCount) is size* (size -1) if the array was unsorted. Calculate the proportion of the array status by first converting (or casting) the integers, swapCount and expectedSwapCount into floating-point, before calculating the proportion. The syntaxes for these calculations are double value = (double) x; double value = (double) x * 1.00; // if x is an integer or // try this if the first fails The proportion can be defined as the number of swaps counted over the expected swap counts, and multiply by 100 to present it in percentage. Finally, return the swapCount.​

Sagot :

We appreciate your time. Please come back anytime for the latest information and answers to your questions. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Your questions are important to us at Westonci.ca. Visit again for expert answers and reliable information.