INSTRUCTION: Answer Question 3 by refering to the funtion (2) below. #include using namespace std; int sortSwapCount(int data[], int size, double &proportion) { int swapCount = 0; for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (data[j] > data[j + 1]) { int temp = data[i]; data[i] = data[i+1]; data[i+1] = temp; swapCount++; } } } double expectedSwapCount = (double)size*(size-1); double swapCount1 = (double)swapCount; proportion = (swapCount1/expectedSwapCount)*100; return swapCount;
INSTRUCTION: Answer Question 3 by refering to the funtion (2) below. #include using namespace std; int sortSwapCount(int data[], int size, double &proportion) { int swapCount = 0; for (int i = 0; i < size - 1; i++) { for (int j = 0; j < size - i - 1; j++) { if (data[j] > data[j + 1]) { int temp = data[i]; data[i] = data[i+1]; data[i+1] = temp; swapCount++; } } } double expectedSwapCount = (double)size*(size-1); double swapCount1 = (double)swapCount; proportion = (swapCount1/expectedSwapCount)*100; return swapCount;
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
INSTRUCTION: Answer Question 3 by refering to the funtion (2) below.
#include <iostream>
using namespace std;
int sortSwapCount(int data[], int size, double &proportion)
{
int swapCount = 0;
for (int i = 0; i < size - 1; i++)
{
for (int j = 0; j < size - i - 1; j++)
{
if (data[j] > data[j + 1])
{
int temp = data[i];
data[i] = data[i+1];
data[i+1] = temp;
swapCount++;
}
}
}
double expectedSwapCount = (double)size*(size-1);
double swapCount1 = (double)swapCount;
proportion = (swapCount1/expectedSwapCount)*100;
return swapCount;
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps