- Sort the array into an alternating sequence of peaks and valleys
- Compare closed 3 items and swap them necessarily
for (int i = 1; i < array.length; i+= 2) { int biggestIndex = maxIndex(array, i-1, i, i+1); if (i != biggestIndex) { swap(array, i, biggestIndex); } }
- TODO
No comments:
Post a Comment