Hi all, i have this mini program that generates randomly 15 to 25 sized array.
This array then randomly generate lower and upper case letters.
So far i have gotten iterative swap to move all lower case to left side and all upper case to right side. Im' required to do it recursively too. but am having a hard time figuring out the base case and general case. here is the code i have for the parts i got working.
void sortArray(char myArray, int left, int right)
if (left >= right)
swap(myArray[left], myArray[(left + right) / 2]);
int last = left;
for (int i = left+1; i < right; ++i)
if (myArray[i] > myArray[left]) // this condition can be refined for "nicer" sorting
sortArray(myArray, left, last-1);
sortArray(myArray, last+1, right);
With recursive algorithms, you'd generally try to break your input into ever smaller pieces, so your exit condition will usually depend on that.