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.
10
votes
3answers
302 views
Implementation of binary min-heap data structure
What do you think is wrong with this code, and how can it be improved? What corner case have I overlooked, if any?
Note: I do not want to use any STL features here, but I'm okay with anything else ...
2
votes
2answers
44 views
Merge N sorted list
Given n sorted lists, merge them.
This is a fairly common question, attributed to plenty of interview question websites.
I'm looking for code-review, optimizations and best practices. I'm also ...
4
votes
1answer
74 views
A functional binary heap implementation
I've implemented a binary heap in F#. It's pure and uses zippers for tree modification.
To test it out I have implemented heap sort using it but it takes 10 seconds to sort a list of 100 000. Regular ...
4
votes
0answers
72 views
Scala heap implementation
I'm a Scala beginner, so it'd be great if anyone would be so kind to give some feedback.
...
5
votes
2answers
213 views
Constraint Programming: Map color problem
I've written some python code to solve the map coloring problem. In my code, I represent the problem using Territory and ...
6
votes
1answer
2k views
Implementation of binary heap in C++
Things I can think of include integer overflow, if the input type is int, etc. But other than that, what do you think is wrong with this code, design-wise, style-wise, and also in terms of other ...
4
votes
3answers
107 views
Time limit exceeded in Heap
I wrote a Heap, but the judge system reports "time limit exceeded" in some tests. I use a sift_down to build, so I don't know why.
Maybe I can improve the build? ...
4
votes
2answers
898 views
Heap implementation using pointer
I know heaps are commonly implemented by an array. But, I wanted to share my pointer implementation and have your feedback(s) :)
General idea:
I convert the index to its binary value and then trace ...
5
votes
1answer
11k views
Implementation of Heap Sort
Is this the correct implementation of Heap Sort using Java? How can it be improved further?
...
6
votes
1answer
503 views
0
votes
1answer
405 views
Heap memory preallocation (intended for games)
Currently, in my games, I'm using new and delete to create entities and components. It works fine, but there are slowdowns when ...
2
votes
1answer
335 views
Maxheap code review in Java
Just looking for some feedback on my implementation of a maxheap mostly relating to style. Trying to create good habits as i learn to program. Constructive criticism is appreciated! Thanks.
Note: ...
3
votes
1answer
85 views
Tree heap Haskell code
I'd like a review of Haskell tree heap code in Turning a tree into a heap in Haskell.
...
3
votes
0answers
205 views
SGI STL pop_heap() method
Throughout the source code, I find that SGI STL pop_heap() has three steps:
put the root value into the last
percolate down
percolate up
Popping an element at ...
2
votes
1answer
1k views
Min Heap implementation with Dijkstra's algorithm
I am implementing Dijkstra's Algorithm using Min Heap to speed up the code.
For a small number of nodes, the code is really running very fast. But for a large number of nodes, my code is throwing ...
2
votes
1answer
1k views