Instruction: Answer question 4 (a,b & c) only (1) Create a C++ project for your assignment 3, with the name format prescribed in the Information section. Add a source file and name it SwapCount. In this file, write the C++ program that will perform the tasks specified in question 2. (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) (i) 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.  (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; // if x is an integer or double value = (double) x * 1.00; // 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. (3) The proportion which is calculated in the function of (2) above will be effectively updated in the main function. Therefore, the function here will determine the status or condition of the data distribution in the array. The function passes the proportion and returns the status. The function signature is stringlistStatus(double proportion) The status must be stored in the variable status before returning it. If the proportion of  count is above 80%, the array is unsorted, if the proportion is above 45% then the array is  partially sorted, if the proportion is above 0%, the array is almost sorted, otherwise, the  array is fully sorted. Return the status. (4) In the main function, do the following: a. Declare and store the following 10 integers in an array elem[].  8, 4, 14, 9, 1, 12, 6, 2, 5, 7 b. Determine the swap-count of the array in (a) by declaring variable ssCount and store the value from the function call sortSwapCount() function in it. Furthermore, declare variable swProportion which will store the proportion of swaps made. Pass this also to the function. Display these values with labels. c. Determine the array status by calling the listStatus function, store it in a variable before displaying it. Remember to pass the proportion in (b) as argument to the function.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Topic Video
Question

Instruction: Answer question 4 (a,b & c) only

(1) Create a C++ project for your assignment 3, with the name format prescribed in the Information section. Add a source file and name it SwapCount. In this file, write the C++ program that will perform the tasks specified in question 2.
(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)

(i) 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

(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; // if x is an integer or
double value = (double) x * 1.00; // 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.

(3) The proportion which is calculated in the function of (2) above will be effectively updated in the main function. Therefore, the function here will determine the status or condition of the data distribution in the array. The function passes the proportion and returns the status. The function signature is stringlistStatus(double proportion)

The status must be stored in the variable status before returning it. If the proportion of 
count is above 80%, the array is unsorted, if the proportion is above 45% then the array is 
partially sorted, if the proportion is above 0%, the array is almost sorted, otherwise, the 
array is fully sorted. Return the status.

(4) In the main function, do the following:
a. Declare and store the following 10 integers in an array elem[]. 
8, 4, 14, 9, 1, 12, 6, 2, 5, 7

b. Determine the swap-count of the array in (a) by declaring variable ssCount and store the value from the function call sortSwapCount() function in it. Furthermore, declare variable swProportion which will store the proportion of swaps made. Pass this also to the function. Display these values with labels.

c. Determine the array status by calling the listStatus function, store it in a variable before displaying it. Remember to pass the proportion in (b) as argument to the function.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY