⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 heapsort.cpp

📁 数据结构与算法分析(C++)(版第二版)源码
💻 CPP
字号:
#include <iostream.h>
#include <stdlib.h>
#include <string.h>

#include "book.h"
#include "compare.h"

#include "maxheap.h"

template <class Elem, class Comp>
void heapsort(Elem A[], int n) { // Heapsort
  Elem mval;
  maxheap<Elem,Comp> H(A, n, n); // Build the heap
  for (int i=0; i<n; i++)        // Now sort
    H.removemax(mval); // Removemax places max at end
}

template <class Elem, class Comp>
void sort(Elem* array, int n) {
 heapsort<Elem,Comp>(array, n);
}

#include "sortmain.cpp"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -