#include
#include
#include <time.h>
#include
class DataGenerator
{
private:
int dataArray[20];
public:
int getNumberOfData()
{
int numberOfData;
std::cout << "Enter number of data: ";
std::cin >> numberOfData;
return numberOfData;
}
int *generateData(int numberOfData)
{
int upperBound;
int lowerBound;
upperBound = numberOfData * 2;
lowerBound = 0;
srand(time(0));
for (int i = 0; i < numberOfData; i++)
{
dataArray[i] = (rand() % (upperBound - lowerBound + 1)) + lowerBound;
}
std::cout << "Data generated successfully " << std::endl;
for (int i = 0; i < numberOfData; i++)
{
std::cout << dataArray[i] << " ";
}
std::cout << std::endl;
return dataArray;
}
};
class AlgorithmSelection
{
private:
int choiceIndex[2];
public:
int *displayMenu()
{
std::cout << "Enter your choice: " << std::endl;
std::cout << "1. Searching Algorithms" << std::endl;
std::cout << "2. Sorting Algorithms" << std::endl;
std::cout << "3. Exit" << std::endl;
std::cout << "Your choice: ";
std::cin >> choiceIndex[0];
bool invalidOption = true;
while (invalidOption)
{
switch (choiceIndex[0])
{
case 1:
std::cout << "Enter your choice: " << std::endl;
std::cout << "1. Linear Search" << std::endl;
std::cout << "2. Binary Search" << std::endl;
std::cout << "3. Exit" << std::endl;
std::cout << "Your choice: ";
std::cin >> choiceIndex[1];
if (choiceIndex[1] < 1 || choiceIndex[1] > 2)
{
std::cout << "Invalid choice" << std::endl;
}
else
{
invalidOption = false;
}
break;
case 2:
std::cout << "Enter your choice: " << std::endl;
std::cout << "1. Bubble Sort" << std::endl;
std::cout << "2. Insertion Sort" << std::endl;
std::cout << "3. Selection Sort" << std::endl;
std::cout << "4. Quick Sort" << std::endl;
std::cout << "5. Merge Sort" << std::endl;
std::cout << "6. Heap Sort" << std::endl;
std::cout << "7. Radix Sort" << std::endl;
std::cout << "Your choice: ";
std::cin >> choiceIndex[1];
if (choiceIndex[1] < 1 || choiceIndex[1] > 7)
{
std::cout << "Invalid choice" << std::endl;
invalidOption = true;
}
else
{
invalidOption = false;
}
break;
case 3:
exit(0);
break;
default: