I need to implement a Heap data structure in C.
While I was doing some research, I see people using buildHeap(), constructHeap() to convert an array into a heap. My question is, instead of implementing those functions, can I just call percolateDown() on the newly added item every time I need to add to the heap?
Thanks!
A heap can be constructed in linear time, while the approach you propose will require O(N log(N)) time. Better construct heap in a separate function for better performance.