
//main.cpp file
#include <iostream>
#include "helper.h"
#include "sorting.h"
using namespace std;
int main() {
unsigned int size;
cout << "Enter the size of the array: ";
cin >> size;
int* Array = new int[size];
unsigned int choice = 0;
do {
fillRandom(Array, size);
cout << "Choose your sorting
cout << "1. Bubble Sort" << endl;
cout << "2. Selection Sort" << endl;
cout << "3. Insertion Sort" << endl;
cout << "4. Merge Sort" << endl;
cout << "5. Quick Sort" << endl;
cout << "6. Shell Sort" << endl; //Optional
cout << "Enter 0 to exit" << endl;
cout << "Your choice: ";
cin >> choice;
cout << "Unsorted Array: ";
print(Array, size);
/****************************
* TODO: Implement what you will do with the choice
*****************************/
cout << "Sorted Array: ";
print(Array, size);
} while(choice!=0);
delete [] Array;
return 0;
}
//helper.h
#ifndef HELPER_H_
#define HELPER_H_
#include <iostream>
#include <stdlib.h>
using namespace std;
void fillRandom(int *Array, const unsigned int size){
for(unsigned int i = 0; i < size; i++){
Array[i] = rand();
}
}
void print(int *Array, const unsigned int size){
for(unsigned int i = 0; i < size; i++){
cout << Array[i] << ", ";
}
cout << endl;
}
#endif /* HELPER_H_ */
//sorting.h
#ifndef SORTING_H_
#define SORTING_H_
void bubbleSort(int* Array, const unsigned int size);
void selectionSort(int* Array, const unsigned int size);
void insertionSort(int* Array, const unsigned int size);
void mergeSort(int* Array, const unsigned int size);
void quickSort(int* Array, const unsigned int size);
void shellSort(int* Array, const unsigned int size);
#endif /* SORTING_H_ */


Trending nowThis is a popular solution!
Step by stepSolved in 3 steps

- Find and correct six (6) errors in the code: // This program uses two arrays to record the names of 5 types of pizza // and the sales numbers for each of these types // The program then finds the best and the worst selling pizzas #include<iostream> #include<string> usingnamespace std; int main() { constint ARR_SIZE=6; // Declare the array size and set it to 5 // Declare the array of pizza names and record values in it int name[ARR_SIZE]=["Pepperoni","Prosciutto","Vegetarian", "Sausage","Supreme","Mozzarella"]; int sales[ARR_SIZE]; // Declare the sales array int worstseller_number, bestseller_number; // The subscripts of the best- and worstseller string worstseller_name, bestseller_name; // The sale numbers of the best- and worstseller for(int i=1; i<ARR_SIZE; i++) // A loop to enter all sales numbers { cout << "Enter sales for " << name[i] << ": "; cin >> sales[i]; } // Make the first element in name[] the bestseller and the worstseller name…arrow_forward1. Simplify the following logic equation: F = ab'c + abcd' + ab'cd' + acd Also draw the circuit before and after simplifications, and comment on savings on number of gates. % savings (number of gates required before modification – number of gates required with simplest form)* 100/(number of gates required after modification)arrow_forwardPointers: P3: Given the following string, after you call func2, if you printed out the array, what would be printed out? string a = {"c","a","n", func2(a); "y"}; void func2(string *arr) { arr[3) - "t"; arr[2]="vi"; %3Darrow_forward
- #include using namespace std; int main() { // Declare two dimensional array here // Declare other variables int numDays; int age; int QUIT = 99; // This is the work done in the getReady () function // Perform a priming read to get the age of the child while (age != QUIT) { // This is the work done in the determineRateCharge() function // Ask the user to enter the number of days // Print the weekly rate // Ask the user to enter the next child's age } // This is the work done in the finish() function cout << "End of program" << endl; return 0; } // End of main() functionarrow_forward#include <iostream> #include <string> using namespace std; int main() { // Declare a named constant for array size here // Declare array here // Use this integer variable as your loop index int loopIndex; // Use this variable to store the batting average input by user double battingAverage; // Use these variables to store the minimim and maximum values double min, max; // Use these variables to store the total and the average double total, average; // Write a loop to get batting averages from user and assign to array cout << "Enter a batting average: "; cin >> battingAverage; // Assign value to array // Assign the first element in the array to be the minimum and the maximum min = averages[0]; max = averages[0]; // Start out your total with the value of the first element in the array total = averages[0]; // Write a loop here to access array values starting with…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





