בעיית QUICKSORT בשפת C
.לפניכם קטע שממיין מילה\מערך בסדר עולה ?מישהו יכול לומר לי אילו שינויים לבצע כדי שהמיון יתבצע בסדר יורד TOKEN-זוהי מילה\מערך שקטע הקוד מקבל LOW-זהו האיבר הראשון במילה\מערך והוא מאותחל באפס HIGH-(האיבר האחרון במערך(ז"א אורך המילה\המערך void ascending_quick_sort(char *token,int low,int high) { int middle; if(low>=high)return; middle=split(token,low,high); ascending_quick_sort(token,low,middle-1); ascending_quick_sort(token,middle+1,high); } int split(char *token,int low,int high) { int part_element=token[low]; for(;
{ while(low<high && part_element <= token[high]) high--; if(low>=high)break; token[low++]=token[high]; while(low<high && token[low] <= part_element) low++; if(low>=high)break; token[high--] = token[low]; } token[high]=part_element; return high; }
.לפניכם קטע שממיין מילה\מערך בסדר עולה ?מישהו יכול לומר לי אילו שינויים לבצע כדי שהמיון יתבצע בסדר יורד TOKEN-זוהי מילה\מערך שקטע הקוד מקבל LOW-זהו האיבר הראשון במילה\מערך והוא מאותחל באפס HIGH-(האיבר האחרון במערך(ז"א אורך המילה\המערך void ascending_quick_sort(char *token,int low,int high) { int middle; if(low>=high)return; middle=split(token,low,high); ascending_quick_sort(token,low,middle-1); ascending_quick_sort(token,middle+1,high); } int split(char *token,int low,int high) { int part_element=token[low]; for(;