文件名称:Heap-sort
介绍说明--下载内容均来自于网络,请自行研究使用
堆排序
堆排序利用了大根堆(或小根堆)堆顶记录的关键字最大(或最小)这一特征,使得在当前无序区中选取最大(或最小)关键字的记录变得简单。 (1)用大根堆排序的基本思想 ① 先将初始文件R[1..n]建成一个大根堆,此堆为初始的无序区 ② 再将关键字最大的记录R[1](即堆顶)和无序区的最后一个记录R[n]交换,由此得到新的无序区R[1..n-1]和有序区R[n],且满足R[1..n-1].keys≤R[n].key ③由于交换后新的根R[1]可能违反堆性质,故应将当前无序区R[1..n-1]调整为堆。然后再次将R[1..n-1]中关键字最大的记录R[1]和该区间的最后一个记录R[n-1]交换,由此得到新的无序区R[1..n-2]和有序区R[n-1..n],且仍满足关系R[1..n-2].keys≤R[n-1..n].keys,同样要将R[1..n-2]调整为堆。 …… 直到无序区只有一个元素为止。 (2)大根堆排序算法的基本操作: ① 初始化操作:将R[1..n]构造为初始堆; ② 每一趟排序的基本操作:将当前无序区的堆顶记录R[1]和该区间的最后一个记录交换,然后将新的无序区调整为堆(亦称重建堆)。 -Heap sortHeap sort heap sort using the root pile ( or small stack stack top ) the record of the keyword maximum ( or minimum ) of this feature, the present disordered select the maximum (or minimum ) keyword records made simple. ( 1 ) with a large root heap sort of basic ideas of the initial file R[1..N] built a large root pile, the pile as the initial disordered regions of the keywords maximum recorded R[1] (i.e. top ) and disordered regions recorded one of the last R[n] exchange, the new R [1..N-1] and disordered zone ordered region R[n], and satisfy the R[1..N-1].keys≤ R[n].key③due to exchange new root R[1] may violate the heap property, so should be the present disordered R[1..N-1] adjustment for reactor. Then again in the R[1..N-1] keyword best record R[1] and the interval of the last record of a R[n-1] exchange, thus get new disordered and ordered R[1..N-2] R[n-1..N], and still meet the relationship between R[1..N-2].keys≤ R[n-1..N].keys, R[1..N-2] also will adjust for reactor. .
堆排序利用了大根堆(或小根堆)堆顶记录的关键字最大(或最小)这一特征,使得在当前无序区中选取最大(或最小)关键字的记录变得简单。 (1)用大根堆排序的基本思想 ① 先将初始文件R[1..n]建成一个大根堆,此堆为初始的无序区 ② 再将关键字最大的记录R[1](即堆顶)和无序区的最后一个记录R[n]交换,由此得到新的无序区R[1..n-1]和有序区R[n],且满足R[1..n-1].keys≤R[n].key ③由于交换后新的根R[1]可能违反堆性质,故应将当前无序区R[1..n-1]调整为堆。然后再次将R[1..n-1]中关键字最大的记录R[1]和该区间的最后一个记录R[n-1]交换,由此得到新的无序区R[1..n-2]和有序区R[n-1..n],且仍满足关系R[1..n-2].keys≤R[n-1..n].keys,同样要将R[1..n-2]调整为堆。 …… 直到无序区只有一个元素为止。 (2)大根堆排序算法的基本操作: ① 初始化操作:将R[1..n]构造为初始堆; ② 每一趟排序的基本操作:将当前无序区的堆顶记录R[1]和该区间的最后一个记录交换,然后将新的无序区调整为堆(亦称重建堆)。 -Heap sortHeap sort heap sort using the root pile ( or small stack stack top ) the record of the keyword maximum ( or minimum ) of this feature, the present disordered select the maximum (or minimum ) keyword records made simple. ( 1 ) with a large root heap sort of basic ideas of the initial file R[1..N] built a large root pile, the pile as the initial disordered regions of the keywords maximum recorded R[1] (i.e. top ) and disordered regions recorded one of the last R[n] exchange, the new R [1..N-1] and disordered zone ordered region R[n], and satisfy the R[1..N-1].keys≤ R[n].key③due to exchange new root R[1] may violate the heap property, so should be the present disordered R[1..N-1] adjustment for reactor. Then again in the R[1..N-1] keyword best record R[1] and the interval of the last record of a R[n-1] exchange, thus get new disordered and ordered R[1..N-2] R[n-1..N], and still meet the relationship between R[1..N-2].keys≤ R[n-1..N].keys, R[1..N-2] also will adjust for reactor. .
(系统自动生成,下载前可以参看下载内容)
下载文件列表
堆排序\堆排序(原创).txt
......\网上资源.txt
堆排序