This repository contains code snippets implementing computer-science concepts which are meant for educational purposes.
This package contains binary min heap implementation backed by primitive integer array.
These are the results of benchmark vs java.util.PriorityQueue<Integer>
.
First, we added 10M random numbers and then polled them. The test was carried
out in 10 iterations. The PriorityQueue
requires a warm-up and then exhibits
similar performance. However, the poll operation is much slower. The times are
calculated as a mean over all iterations with standard deviation.
You can check out the benchmark implementation.
BinaryMinHeap#push: 492.062327ms +/- 66.602692ms
PriorityQueue<Integer>#add: 971.143220ms +/- 960.383883ms
BinaryMinHeap#pop: 2852.478666ms +/- 62.338150ms
PriorityQueue<Integer>#poll: 12725.931642ms +/- 142.818597ms