堆积排序法(HeapSort).pptVIP

  • 15
  • 0
  • 约7.7千字
  • 约 55页
  • 2017-03-09 发布于天津
  • 举报
堆积排序法(HeapSort)

Data Compression Multimedia Communication Lab Data Structures 資料結構 Chapter 12-1 Sorting Straight Selection Sort Select the i-th smallest element and exchange with the i-th element of the sequence. Time complexity is O(n2) Straight Selection Sort - demo Straight Selection Sort - code for i ← 1 to n – 1 do small ← a[n]; idx ← n; for j ← i to n – 1 do if (a[j] small) then small = a[j]; idx = j; x[idx] = x[i]; x[i] = small Heapsort Delete the root of a heap, and put the deleted node into a list. Iterate until the heap is empty. O(n lg n) Sorting Using a Heap 堆積排序法(Heap Sort)

文档评论(0)

1亿VIP精品文档

相关文档