0

So, I was given this specification for a quicksort algorithm and I have no idea where to start.

Create a template version of the QuickSort algorithm that will work with any data type.

Demonstrate the template with a drive function.

If it was to do a quicksort, I could easily do that, but I don't even know where to start. Any suggestions/tips? I did the rest of my project just fine, but is there a more efficient way I could do some of those things?

```
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
void pattern(unsigned int n);
void super_write_vertical(int number);
void Npattern(int m);
int main()
{
const int SIZE = 10; //Array Size
unsigned int n;
int number;
int m;
int qs[SIZE] = {7, 3, 9, 2, 0, 1, 8, 4, 6, 5};
n = 840;
cout << "For Item #1";
cout << "Pattern " << n << ":" << endl;
pattern(n);
n = 4000;
cout << "Pattern " << n << ":" << endl;
pattern(n);
number = -361;
cout << "\nFor Item #2";
cout << "Super Write Vertical " << number << ":" << endl;
super_write_vertical(number);
number = -1234;
cout << "Super Write Vertical " << number << ":" << endl;
super_write_vertical(number);
number = 1234;
cout << "Test Case to prove third case without negatives:" << endl;
super_write_vertical(number);
m = 3;
cout << "\nFor Item #3" << endl;
cout << "Exponent " << m << ":" <<endl;
Npattern(m);
m = 4;
cout << "\nExponent " << m << ":" << endl;
Npattern(m);
cout << endl;
cout << "\nFor QuickSort" << endl;
for(int i = 0; i < SIZE; i++)
{
cout << qs[i] << " ";
}
cout << endl;
for(int i = 0; i < SIZE; i++)
{
cout << qs[i] << " ";
}
cout << endl;
return 0;
}
void pattern(unsigned int n)
{
if(n <= 8484)
{
cout << n << endl; //Will print out the values of n
pattern(n * 2);
cout << n << endl; //This one will print out the values of n that were being stored in the stack
}
return;
}
void super_write_vertical(int number)
{
if(number < 0)
{
cout << "-" << endl;
super_write_vertical(abs(number)); //Will change that negative number to positive using the absolute value
}
else if(number < 10)
{
cout << number << endl; //will print out the only number that was given if there was one
}
else
{
super_write_vertical(number / 10); //This will print out everything but the last digit
cout << number % 10 << endl; //This will print out the very last digit
}
}
void Npattern(int m)
{
if(m == 0)
{
return;
}
Npattern(m-1);
cout << m << " ";
Npattern(m-1);
}
```