A minmax heap is a type of double-ended priority queue data structure based on a complete binary tree.
Questions tagged [minmax-heap]
22 questions
0
votes
1 answer
Min-Max heap delete max element
I'm confused about the final image after a delete-max operation. When 87 is deleted does 48 get brought to the spot that 87 once held? Does the rest of the tree not change after?
Min-max heap original
user5476593
0
votes
2 answers
Check if an heap is a min-max heap
I've written a min-max heap, i.e. an heap where finding the minimum and the maximum are constant operations. Now I want to create tests for my class, so I decided to implement a function that checks if a heap is a min-max-heap. Here it is, but I'm…

nbro
- 15,395
- 32
- 113
- 196
0
votes
1 answer
Understand how min-max heap looks like after after delete-min and delete-max
I have a specific question about min-max heap related problem in Java.
If you have inputs in this order:
71, 8, 41, 100, 60
Would the tree look like the following?
8
100 41
70 60
What about…

Thank you for your help
- 57
- 2
- 8
-1
votes
1 answer
Is finding the min/max of BST considered to be O(1) time?
I was building a queue using a BST, but I realized that a min/max heap might be better.
However, a BST might work, since if we store a reference to head/tail in the BST, then lookup is very close to O(1)..for example:
(5)
/ \
…

Alexander Mills
- 90,741
- 139
- 482
- 817
-1
votes
1 answer
max_heapify iterative way to go down the heaps to get the next level nodes
I am trying to write a iterative control loop instead of recursion because it is more efficient can someone tell me if my code makes sense:
Recursive version:
def max_heapify(array, i):
left = 2 * i
right = 2 * i + 1
length = len(array) - 1 # for…

Poala
- 5
- 2
-1
votes
1 answer
How to fix bug in min heap insertion / extract functions?
I compile like this:
clang++ -std=c++11 test.cpp MinHeap.cpp -o test
Implementation is failing test2 "Assertion failed: (array[i] == i), function test2, file test.cpp, line ...
Abort trap: 6". The test2 is creating an array of size 10000 (with ints…

ty-young
- 3
- 1
-3
votes
1 answer
How should I implement recursion method to find number of ways to form max heap in C++?
If dp[n] stores the number of ways of forming max heap containing n elements, then we have.
dp[n] = nCr(n - 1, n1) * dp[n1] * dp[n2];
i.e.
Select n1 elements out of n - 1 for left subtree.
Elements in left subtree can form max heap in dp[n1]…

Prateek Oraon
- 101
- 1
- 8