Question
Need help completing QuickSort function which calls my partiton function getting wrong output; input file contains AbracadaBra OUTPUT should be: 10 7 0 3 5
Need help completing QuickSort function which calls my partiton function
getting wrong output;
input file contains "AbracadaBra"
OUTPUT should be:
10 7 0 3 5 8 1 4 6 9 2
Need to do:
REFERENCE code:
---------------------------------------------------------
my code so far:
#include
void readFromFile(string &S, string filename); void convertToLower(string &S); bool lessThan(const string &S, int first, int second, int pass); int partition(const string &S, vector
int main(int argc, char *argv[]) { string S; string filename = argv[1]; vector quicksort(S,index,low,high); for(int k=0; k cout void readFromFile(string &S, string filename) { string buffer; ifstream ifile; ifile.open(filename); while (getline(ifile, buffer, ' ')) { string Stemp; Stemp = buffer; S = S+Stemp; } } void convertToLower(string &S) { transform(S.begin(), S.end(), S.begin(), ::tolower); } int partition(const string &S, vector while (i=low && lessThan(S,indices[j] ,pivot, 0) == false ){ j--; } if(i } swap(indices[high],indices[i]); return i; } bool lessThan(const string &S, int first, int second , int pass) { if(S[first] S[second]){ return false; } else //return T OR F return lessThan(S, first+1, second+1,0); } int quicksort(const string &S,vector } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started