Questions tagged [max-heap]
148 questions
0
votes
1 answer
Where to increase max heap for Fuse ESB router?
About once per month, our router component hangs, halting traffic. It logs a "OutOfMemoryError: Java heap space" error. I think it's consistently using about .5 GB of physical memory.
It looks like config files are placed in…

bwfrieds
- 341
- 3
- 20
0
votes
0 answers
How to maintain a Java TreeMap size to be a constant while adding key-value pairs into the TreeMap?
CODE IS HERE is a nice and simple example of TreeMap in java to keep track of the key-value pairs added to the map in a sorted order. However, I am unsure on how to ensure that I only keep 10 items in the TreeMap. How to ensure that the size of the…

tnecniv
- 147
- 1
- 1
- 11
0
votes
1 answer
Pascal Max_Heapify
I did these in pascal.
Proceure Max_Heapify(a:Table;i:longint);
var tmp,l,r,k:longint;
begin
l:=2*i;
r:=2*i+1;
if (heapsize>=l)and(a[i]=r)and(a[i]i then
begin
…

Linh T. Vu
- 1
- 1
0
votes
1 answer
Using recursion to identify an array as a MaxHeap
On this implementation of Priority Queue I have to use recursion to determinate if the array that I receive as a parameter of the method IsMaxHeap is a max heap.
I want to be sure I evaluate all the cases that could make this work or not work…

Lu MON
- 107
- 8
0
votes
1 answer
Priority Queue using a Max-Heap Data Structure
I am implementing a priority queue using a max-heap data structure in Python. I'm using several names that have numbers associated with them as their priority (9 being the highest and 1 being the lowest). The issue I am facing is that when I dequeue…

coleworld
- 35
- 1
- 7
0
votes
1 answer
Heapsort not working in Javascript
I am trying to implement heapsort in Javascript, but there is a undefined element at array.length - 2 and the element at index 0 is unsorted.
Here is the code:
var heapSort = function(array) {
var swap = function(array, firstIndex, secondIndex)…

hopper
- 29
- 1
- 9
0
votes
2 answers
Heap sort, Understanding the basics
As a disclaimer I am new to this site and therefore, do not know very well how to ask questions. Please don't be too harsh because I really am trying to just understand how some of these concepts work. If i am missing understanding near the…
0
votes
1 answer
from where we need to start in max-heapify algorithm?
I need to no do we have a way to apply max-heapify algorithm?do we have to apply it from bottom to top or top to bottom?or can we apply to the places that heap property is not there? when we are going to maintain the heap property in a tree.
can…

Sanjaya
- 156
- 1
- 9
0
votes
3 answers
Stuck with deleting node from tree
I'm trying to build a max heap in VC++ using Visual Studio 2008 v9.0.30729.1 SP.
In the tree, each node looks like:
typedef struct node{
struct data_t *data;
struct node_t *left;
struct node_t *right;
}node_t;
A single node creation…

metsburg
- 2,021
- 1
- 20
- 32
0
votes
1 answer
c++ priority_queue initialization. Why can we ignore const Compare&
class Star {
public:
// The distance between this star to the Earth.
double distance() const { return sqrt(x_ * x_ + y_ * y_ + z_ * z_); }
bool operator<(const Star& s) const { return distance() < s.distance(); }
int ID_;
double x_, y_,…

BufBills
- 8,005
- 12
- 48
- 90
0
votes
1 answer
Maxifying heap in java - Stack Overflow error
I have written the following program for maxifying a heap in Java.
package heap;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class HeapMaxify
{
public static void main(String[] s)
{
…

mbsingh
- 499
- 10
- 26
0
votes
1 answer
Is it possible to use a min heap as a max heap?
I've implemented a minHeap class so I am curious if, without modifying the code, it would be possible to use the minHeap class as a max heap?

user3601101
- 3
- 1
0
votes
1 answer
Static binary search tree over ordered set with different frequency
Let A = {a1, a2, . . . , an} be a set of distinct items totally ordered such that ai< aj iff i < j. Assume that over a long sequence of m accesses to items in A, ai is accessed q(i)≥1 times. I want an algorithm to find a binary search tree T where…

abdolahS
- 663
- 12
- 35
0
votes
2 answers
Standard Collection for MINIMUM or MAXIMUM HEAP
I want to know that what class from java's standard collection can be made a parent class of Min-Heap or Max-Heap?
I develop the class Heap which can convert the heap to min or max depending upon strategy and used methods like add, toString, toArray…

user2801336
- 187
- 1
- 2
- 10
0
votes
2 answers
MaxHeapify call yields numbers not in the original array
I'm working on implementing a max-heap from pseudo code in my book and I'm getting strange results after calling the "buildMaxHeap" function. For example, an integer array intHeap with elements {20, 5, 10, 12, 15, 8, 2, 6, 2, 9} is resulting in…

Zach
- 3
- 2