function partition(num,begin,end){
var pivot= num[begin];
var beginning = begin-1 ;
var ending = end+1 ;
// over here the while loop says that the argument is true but,
// what is true, and how does this thing work
while (true) {
beginning++;
while ( beginning< end && num[beginning] < pivot)
beginning++;
ending--;
while (ending>begin && num[ending] > pivot)
ending--;
if (beginning < ending)
swap(num, beginning, ending);
else
return ending;
}
function swap(num, begin, end) {
var temp = num[begin];
num[begin] = num[end];
num[end] = temp;
}
函数分区中的while循环,它可以工作,但我想知道它是如何工作的以及代码的效率如何,谢谢