堆(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();

 

posted @ 2021-03-15 17:03  AlwaysBlue  阅读(97)  评论(0)    收藏  举报