Post, Code and Quiet Time.
  • Home
Sign in Subscribe

MaxHeap

A collection of 1 post
Codes

c++: Max Heap Template

https://en.wikipedia.org/wiki/Min-max_heap My simple implementation of max heap. Change the compare from > to < in below codes, you will get a min heap. template class MaxHeap { public: MaxHeap() { size_ = 0; capacity_ = 2; heap_ = new T[capacity_]; } MaxHeap(int capacity) { if (capacity >= 2) { heap_ = new T[capacity]
Jul 10, 2018 1 min read
Page 1 of 1
Post, Code and Quiet Time. © 2023
Powered by Ghost