Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int g = first, h = last;
- int midIndex = (first + last) / 2;
- int dividingValue = list[midIndex];
- steps +=5;
- do
- {
- while (list[g] < dividingValue){ g++; steps +=1;}
- while (list[h] > dividingValue){ h--; steps +=1;}
- steps +=2;
- if (g <= h)
- {
- //swap(list[g], list[h]);
- int temp = list[g];
- list[g] = list[h];
- list[h] = temp;
- g++;
- h--;
- steps +=6;
- }
- }
- while (g < h);
- if (h > first){
- quickSort (list,first,h);
- steps++;
- }
- if (g < last){
- quickSort (list,g,last);
- steps++;
- }
- steps +=2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement