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
posted @ 2020-08-02 22:48 执着于风 Views(112) Comments(0) Diggs(0)
//大根堆的构建、结点的插入和删除与此完全类似 #include<iostream> using namespace std; class MinHeap { public: int* heap;//存放小根堆中元素的数组 int maxHeapSize;//小根堆最多允许元素个数 int curr Read More
posted @ 2020-07-28 18:07 执着于风 Views(1254) Comments(0) Diggs(0)
#include<iostream> using namespace std; struct BinaryTreeNode{ int ltag,rtag; char data; BinaryTreeNode* leftChild; BinaryTreeNode* rightChild; Binary Read More
posted @ 2020-07-28 18:06 执着于风 Views(758) Comments(0) Diggs(0)
#include<iostream> using namespace std; struct BinaryTreeNode{ char data; BinaryTreeNode* leftChild; BinaryTreeNode* rightChild; BinaryTreeNode(char n Read More
posted @ 2020-07-28 18:03 执着于风 Views(572) Comments(0) Diggs(0)
#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
posted @ 2020-07-28 18:02 执着于风 Views(209) Comments(0) Diggs(0)
#include<iostream> #include<queue> #include<memory.h> #define maxSize 100 using namespace std; struct edgeNode { int dest; //邻接顶点的数组下标 //int weight; 权 Read More
posted @ 2020-07-28 18:00 执着于风 Views(374) Comments(0) Diggs(0)
#include <vector> using namespace std; #include<iostream> #include <cstdio> #include <cstring> #define maxn 200005 struct Edge { int v,next; }edge[max Read More
posted @ 2020-07-28 17:59 执着于风 Views(129) Comments(0) Diggs(0)
#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
posted @ 2020-07-28 17:57 执着于风 Views(173) Comments(0) Diggs(0)
#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
posted @ 2020-07-28 17:56 执着于风 Views(99) Comments(0) Diggs(0)
#include<iostream> #include<stdio.h> #include<queue> using namespace std; int main() { priority_queue<int, vector<int>, greater<int> > minHeap; cout<< Read More
posted @ 2020-07-28 17:55 执着于风 Views(394) Comments(0) Diggs(0)