七种排序算法Java版,最常用的7种
maxIndex = right; } if (currentIndex == maxIndex) { isHeap = true; } else { int temp = array[currentIndex]; array[currentIndex] = array[maxIndex];
array[maxIndex] = temp;
currentIndex = maxIndex;
right = currentIndex * 2 + 2;
left = currentIndex * 2 + 1;
}
}
}
public static void main(String[] args) {
int data[] = { 2, -1, 5, 4, 6, 8, 7, -3 };
Sort.displayData(data);
Sort.bubbleSort(data);
Sort.displayData(data);
}
}