## nabil1983

Hello

Im trying to understand and explain how the quick sort code actually works, i unable to understand or xplain line 4 to 11.
Can ne of u xplain to me briefly what those lines actually do in the code algorithm....
Apreciate ne help.

``````do {
while(strcmp(array[i].Genre,x)<0 && i<right) i++;       //line 2
while(strcmp(array[j].Genre,x)>0 && j>left) j--;	        //line 3

if(i<=j) {				                    //line 4
temp = array[i];		                   //line 5
array[i] = array[j];		                  //line 6
array[j] = temp;		                  //line 7
i++; j--;			                 //line 8

}
}while(i<=j);		                  //line 9

if(left<j) quick_sort(array, left, j);		     //line 10
if(i<right)quick_sort(array, i, right);		     //line 11
}``````

## perniciosus 19

Try reading up on quicksort in general... The loop (lines 2-9) make sure that all the low values are in one range and the high values in the other... The recursive calls (lines 10,11) then does the same for these fixed subsections, untill the trivial case of one or two elements..

commented: Thanks +1