堆(heap)
深入理解堆:
https://blog.csdn.net/summerlq/article/details/82747940
数据结构:堆
https://www.jianshu.com/p/6b526aa481b1
堆的实现
include<stdio.h> include<stdlib.h> include<assert.h> typedef int HeapType; typedef struct MaxHeap{ HeapType *data; int MaxSize; /*数据容量*/ int count; /*当前存储的容量*/ }MaxHeap; int size(MaxHeap *heap){ return heap->count; } int isEmpty(MaxHeap *heap){ return heap->count == 0; } void InitHeap(MaxHeap *heap, int size){ /*初始化函数*/ heap->MaxSize = size; heap->count = 0; heap->data = (HeapType *)malloc((mh->MaxSize+1)*sizeof(HeapType)) } void AdjustDown(); void AdjustUp(); void InsertMaxHeap(); HeapType Top();
有什么不对或不懂的可以提出来一起讨论呀

浙公网安备 33010602011771号