摘要:
/*——1——*/ void quick_sort(int a[], int left, int right){ if (left < right) { /* at the beginning, we could choose any element as a pivot element*/ /* 阅读全文
摘要:
/*crate a new array to put the elements sorted*/void MergeSort(int a[], int n){ int *TmpArray; TmpArray = (int*)malloc(n*sizeof(int)); if (TmpArray != 阅读全文
摘要:
void Insertsort(int a[], int n){ int i, j; int Tmp; for (i = 1; i < n; i++)//from the second element for (j = i - 1; j >= 0 && a[j] > a[j + 1]; j--){ 阅读全文
摘要:
代码: void HeapSort(int a[], int n){ int Tmp; for (int i = n / 2; i >= 0; i--) PercDown(a, i, n); /*build a heap; we should know that intinially we put 阅读全文