Write the program that allows the user to sort using the Bubble Sort, Selection Sort, Insertion Sort and Shell Short The program should be able to read in data from a binary file. The first element of the binary file will be used to tell how many elements to read in. Once all the data has been read in, the program should sort the data. The user should be able to choose which algorithm to use to sort the data. The program should print the time before and after the sort. The last part of the program should prompt the user for a lower and upper bound. These two value should then be used to decide how much and which part of the array will be display. You should test all of the sorts on each of the data files. There are a number of files (10numbers.zip, etc.) of increasing size that you can utilize for testing purposes.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Question

Using these codes as guide

BinaryFileRead.cpp

// BinaryFileRead.cpp : Defines the entry point for the console application. //

#include "stdafx.h"

#include <iostream>

using namespace std;

int main()

{

int *arrayToSort;

char fileName[50];

int size,readVal;

cout << "Enter a filename to sort => ";

cin >> fileName;

FILE *inFile;

fopen_s(&inFile,fileName, "rb");

fread(&size, sizeof(size), 1, inFile);

arrayToSort = new int[size];

for (int i = 0; i < size; i++) {

fread(&readVal, sizeof(readVal), 1, inFile);

arrayToSort[i] = readVal;

}

fclose(inFile);

return 0;

}

Timing.cpp

// Timing.cpp : Defines the entry point for the console application. //

#include "stdafx.h"

#include <iostream>

#include <time.h> //ctime

#include <sys/timeb.h> //_timeb _ftime_s

using namespace std;

int main()

{

struct _timeb timebuffer;

char timeline[26];

_ftime_s(&timebuffer);

ctime_s(timeline,sizeof(timeline), &(timebuffer.time));

printf("The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20]);

system("pause");

return 0;

}

Write the program that allows the user to sort using the Bubble Sort, Selection Sort, Insertion Sort  and Shell Short  The program should be able to read in data from a binary file.  The first element of the binary file will be used to tell how many elements to read in.  Once all the data has been read in, the program should sort the data.  The user should be able to choose which algorithm to use to sort the data.  The program should print the time before and after the sort.  The last part of the program should prompt the user for a lower and upper bound.  These two value should then be used to decide how much and which part of the array will be display.  You should test all of the sorts on each of the data files.  There are a number of files (10numbers.zip, etc.) of increasing size that you can utilize for testing purposes. In a separate word document include a short writeup for each sort that looks something like this:

Insertion Sort:
1,000,000 Random: 5 minutes
1,000,000 Sorted: 30 seconds
Algorithm Description: This algorithm performed faster than Bubble an Selection on a sorted list because ...
Algorithm Runtime Classification: ___ Best Case ___ Worst Case ___ Average Case
 
Note:
In your description or at the end be sure to a mention of the 'Big O' performance compared to other algorithms when justifying why certain algorithms perform significantly better than others.
 
All binary files may have duplicate numbers in them. Make sure your sorts are able to handle these cases.Two sample programs for reading from a binary file in the specified format and timing have been included. We will look at these in class sometime this coming week, so you understand how they work.
 
You must use Visual Studio 2019/C++ 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

for the timing. 
 can you do similar to this: 

Timing.cpp

// Timing.cpp : Defines the entry point for the console application. //

#include "stdafx.h"

#include <iostream>

#include <time.h> //ctime

#include <sys/timeb.h> //_timeb _ftime_s

using namespace std;

int main()

{

struct _timeb timebuffer;

char timeline[26];

_ftime_s(&timebuffer);

ctime_s(timeline,sizeof(timeline), &(timebuffer.time));

printf("The time is %.19s.%hu %s", timeline, timebuffer.millitm, &timeline[20]);

system("pause");

return 0;

}

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning