首页 > TAG信息列表 > PercDown

排序算法:堆排序

  // 算法1 :调整为最小堆,再申请空间存放排好序的数组 // T = O( NlogN ) void Heap_Sort ( ElementType A[], int N ) { BuildHeap ( A ); // O( N ) for ( i=0; i<N; i++ ) TmpA[i] = DeleteMin( A ); //弹出堆顶 O( logN ) for ( i=0; i<N; i++

7-38 寻找大富翁 (25分)--排序

多提交几次就不超时了(#滑稽) 1 #include<iostream> 2 using namespace std; 3 long int a[1000005]; 4 long int N; 5 inline void swap(long int* a, long int* b) 6 { 7 int temp = *a; 8 *a = *b; 9 *b = temp; 10 } 11 inline void percdown(long int

基础排序之堆排序(C语言小堆版)

堆排序 #include<stdio.h> typedef int ElementType; int arr1[11]={0,2,87,39,49,34,62,53,6,44,98}; void Swap(int* a,int* b) { int temp=*a; *a=*b; *b=temp; } void PercDown(int A[], int i, int N) { int child; ElementType Tmp; for