Questions tagged [heap]

A heap is a tree-based data structure that satisfies the heap property. For questions about memory allocated from the system heap, use the [memory-management] tag.

Filter by
Sorted by
Tagged with
6
votes
4answers
14k views

MinHeap implementation

Please comment on this. ...
12
votes
5answers
7k views

Simple binary heap in C#

I've written a simple binary heap in C# and I want to know if it has any problems or if I can make it better. ...
5
votes
1answer
2k views

A* search algorithm: open set and heap

I'm working on an A* search algorithm implemention and this is what I came up with for the open list: ...
3
votes
2answers
208 views

RFC 1951 “Deflate” compression

This is a little project I did over Christmas, I wanted to understand a bit more about how RFC 1951 (https://www.ietf.org/rfc/rfc1951.txt) compression worked, mostly out of curiosity really. RFC 1951 ...
1
vote
2answers
298 views

Fibonacci heap in C - follow-up

(See the previous iteration.) I have incorporated some points made by ChrisWue and refactored my Fibonacci heap implementation: fibonacci_heap.h ...
14
votes
7answers
1k views

Binary Heap where a comparison delegate is used

I currently have a Generic Implementation of a BinaryHeap. It must be able to maintain it's integrity with elements that may or may not implement ...
5
votes
3answers
2k views

Indexed Fibonacci heap implementation

I implemented two versions of a Fibonacci heap one using a unordered map (mapping keys to their nodes) so that the client can call decrease in \$O(1)\$ average and ...
12
votes
3answers
1k views

Given some integers, return the k most frequent elements

Given a non-empty array of integers, return the k most frequent elements. For example, given [1,1,1,2,2,3] and k = 2, return <...
5
votes
2answers
3k views

Merge k Sorted Arrays

Please review my answer for this interview question: Merge k sorted arrays, using min heap. ...
5
votes
1answer
567 views

Heap selection sort in Java

See the next iteration. I designed and implemented this adaptive heap sort in Java. It works as follows: Copy the range to be sorted into auxiliary array \$A\$ Create an empty run heap \$H\$ Scan \$...
4
votes
2answers
3k views

Maximum Priority Queue using Heap

I have written this program for Maximim Priority Queue after studying from Introduction to Algorithm . I want to improve my code. Is there any other method to implement Priority Queue instead of Heap? ...
6
votes
2answers
7k views

Min & Max heap implementation

As follows I have implemented Min and Max heap data structure, using an array for storing elements. I would need a code review, please. Please, spare recommendations for generic implementation as they ...
4
votes
0answers
131 views

Heap update generic algorithms

In the standard library, there are no algorithms for element updates. This makes it unsuitable as a queue for a Dijkstra's algorithm, for example. Thus I implemented generic heap update functions with ...
2
votes
2answers
2k views

Min&Max Heap implementation in .NET

Overview I was doing some performance optimization patterns when I stumbled upon PriorityQueue and I implemented for that reason ...
2
votes
2answers
484 views

Heapsort for arbitrary ranges in Java

I plan to work on Introsort, which requires a working implementation of heap sort. Also, the heap sort implementation must be able to sort arbitrary ranges within an array, which, in turn, requires ...
2
votes
1answer
548 views

(Min)Heap implementation

Being that I needed a min-heap implementation for a project, I implemented one. Now that it's finished I though about having a review for it. I'm interested in all aspects: readability, performance, ...
0
votes
1answer
140 views

Heap selection sort - follow-up

See the previous and initial iteration. I got rid of Run objects and just maintain two integer arrays in the RunHeap: one for ...