我目前正在编写一个程序,它读取一个非常大的文本文件,并按字母顺序和字符长度对文本文件进行排序.我实施了一个快速排序来做到这一点.即时通讯的问题,希望能得到一些明确的解决方案是我有两种方法可以解决问题.这里是quickSortLen的代码
void SortingCompetition::quickSortLen(vector<char*>& words, int left, int right){
int i, j, middle, underMiddle, overMiddle;
char* pivot;
//Median of FIVE pivot point
i = left;
j = right;
middle = left + (right - left) / 2;
underMiddle = left + (middle - left) / 2;
overMiddle = middle + (right - middle) / 2;
//Right and Left
if(strlen(words[right]) < strlen(words[left]))
{
swap(words[right], words[left]);
}
// 4/5 and left
if(strlen(words[overMiddle]) < strlen(words[left]))
{
swap(words[overMiddle], words[left]);
}
//Middle and Left
if(strlen(words[middle]) < …
Run Code Online (Sandbox Code Playgroud)