import java.util.Arrays; public class My { public void heapSort(int[] arr) { // 前提:根节点为0号结点,结点总数为n // 若当前结点为i,则其左孩子为2*i+1,右孩子为2*i+2 // 最后一个非叶子结点为n/2-1 Read More
//大根堆的构建、结点的插入和删除与此完全类似 #include<iostream> using namespace std; class MinHeap { public: int* heap;//存放小根堆中元素的数组 int maxHeapSize;//小根堆最多允许元素个数 int curr Read More
#include<iostream> #define N 100 using namespace std; struct Graph{ int vertex_number; int edge_number; char vertex[N]; int edge[N][N]; }; Graph* G; i Read More
#include<iostream> using namespace std; void quick_sort(int array[], int start, int end) { if(start>=end) return; //递归终止条件 int i = start; int j = end; Read More
#include<iostream> #include<stdio.h> #define maxn 100 using namespace std; void merge(int arr[],low,mid,high){ int i,j,k; int n1=mid-low+1; int n2=hig Read More