Hi, I could really use some clues how to program this task. I'm bad at programing, so I have no idea where to start.
task:
Which of the matching algorithms you selected is faster with 100,000 not sorted out data?
Which of the matching algorithms you selected is faster with 100,000 reverse-sorted out data?
Algorithms:(need to program 2)
Bubble sort
Insertion sort
Selection sort
Heap
Shell
Merge
Quick
Radix
My questions:
1. how do I create a file with 100000 elements to read?
2. what is not sorted out and reverse sorted out elements and how to make them.
3. can you show some examples how to program?
Thank You for your time.
(I tried translating task from my language)
vector<double> BubbleSort(vector<double>& vec1){
bool swapped = true;
int n = vec1.size();
int j = 0;
double tmp;
while (swapped) {
swapped = false;
j++;
for (int i = 0; i < n - j; i++) {
if (vec1[i] > vec1[i + 1]) {
tmp = vec1[i];
vec1[i] = vec1[i + 1];
vec1[i + 1] = tmp;
swapped = true;
}
}
}
return vec1;
}
Most of these algorithms can be found on the internet and modified quickly to do what you need. http://www.cplusplus.com/forum/general/233938/
as for filling a file. use fstream and a number generator if you really need to create files that size for un-encrypted. idk about encrypted.
also just a note, these algorithms are set up for vectors of doubles, if you are using a different type of input you will want to change that.