Explore IDNLearn.com to discover insightful answers from experts and enthusiasts alike. Get comprehensive answers to all your questions from our network of experienced experts.
(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 :
Your participation means a lot to us. Keep sharing information and solutions. This community grows thanks to the amazing contributions from members like you. IDNLearn.com has the solutions to your questions. Thanks for stopping by, and see you next time for more reliable information.