Skip to main content

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.

7 votes
4 answers
523 views

Traversal Heap Sort (No Extractions)

I developed a heap sort variant that sorts a heap through traversal. Unlike in the standard heap sort, the algorithm does not remove the min element from the heap instead it traverses all the nodes of ...
ariko stephen's user avatar
8 votes
2 answers
442 views

Heap sort optimization

I tried to optimize heap sort algorithm. Instead of recursion, I used iteration: ...
iskander's user avatar
  • 121
4 votes
2 answers
306 views

C++ heap allocator using an explicit free list

Description I've written a heap allocator in C++ using an explicit free list for organization. I've also written a series of unit tests and a microbenchmark using Catch2. At time of writing I've ...
pdm's user avatar
  • 307
2 votes
2 answers
275 views

implementing a min/max Heap in rust

I am more on data analyst than a programmer, but I do enjoy coding for fun. I tried to implement a Heap in rust. I would appreciate any return you may have, so I can improve. ...
RomainL.'s user avatar
  • 314
14 votes
4 answers
4k views

Max-heap implementation in C

I have tried to implement my Heap in C. The following are the 13 operations defined: build_maxheap insert exctract_max (delete heap max root) max_delete (delete an element or key) max_heapify clear ...
V_head's user avatar
  • 555
5 votes
1 answer
884 views

Arbitrary Length Input in C

From scanf() to fgets(), we need to first specify the maximum length of the string input, due to which input gets a limitation, ...
Darth-CodeX's user avatar
5 votes
1 answer
107 views

Bidirectional Dijkstra d-ary heap

This is my very first data structure written in Perl for a d-ary heap: ...
coderodde's user avatar
  • 32k
2 votes
3 answers
561 views

Adjusting heaps efficiently

Introduction and context I am working on a small application which involves sorting 20GB files as one of the operations. This is being done, due to memory constraints, by breaking them into ~1GB ...
Oliver Schönrock's user avatar
5 votes
2 answers
744 views

Binary Heap Structure Class C++

I wrote a binary heap structure class in C++. It is a templated class with a comparison type as one of the template parameters to allow for a min or max heap. I have not written anything in C++ in a ...
mastmartelli's user avatar
1 vote
1 answer
93 views

Assigning Tasks to Entities (or some other entity) based on Priority

Main Questions: Is my runtime analysis correct? Is my approach optimal or close to it? Is there a better way and/or improvements? Objective: Write an algorithm to assign ...
MPC's user avatar
  • 61
2 votes
1 answer
244 views

Sink algorithm in Max Heap Correctness

I am trying to determine the correctness of a helper method within my MaxHeap class. The goal of this helper method is, given the index of any node in the Max Heap, sink it to the correct level in the ...
MPC's user avatar
  • 61
2 votes
2 answers
105 views

Trying for an efficient and readable heap-sort implementation

I'm looking for any sort of optimization and/or conventional practice tips, such as using the appropriate data types and naming my variables appropriately. ...
mastmartelli's user avatar
8 votes
1 answer
497 views

Binary Heap Implementation in Rust

I'm learning Rust by implementing basic data structures and algorithms. I implemented a binary heap (max heap): ...
ryanzidago's user avatar
3 votes
1 answer
369 views

Heap insertion and deletion Implementation using Python

I have implemented basic max heap insertion and deletion functions without recursion ...
minglyu's user avatar
  • 133
2 votes
1 answer
306 views

Priority Queue implementation for top k frequent elements leetcode in Ruby

While working on the following leetcode problem: https://leetcode.com/problems/top-k-frequent-elements/ I used a Priority Queu implementation in Ruby. I have learned how to implement a Priority Queu ...
Steven Aguilar's user avatar

15 30 50 per page
1
2 3 4 5
11