Questions tagged [heap]

A heap (data structure) is a tree that is ordered with respect to depth. Heap can also refer to process memory set aside for dynamic allocation.

0
votes
0answers
18 views

best-first search implementation using heaps

I'm attempting to implement the basic greedy 'best first search' algorithm using heaps and I am close but stuck. Any help would be very sincerely appreciated. I have a graph class which reads in ...
0
votes
0answers
53 views

How to statically identify dynamic heap allocation?

I'm about to remove "as many as possible" dynamic heap allocation in my application and I wonder how I can make sure I didn't miss anything.Currently I'm looking for a way to easily or even ...
2
votes
1answer
36 views

Which is faster? Using a custom Comparator class or lambda function

I am trying to create a sorted map in java (sorted in decreasing order of key). I triedMap<Integer,Integer> map=new TreeMap<>((a,b)->(b-a));Would it create any performance impact ...
-3
votes
3answers
61 views

What exactly is C++'s behavior regarding pointers and using functions to initlize them to the heap? [on hold]

Currently having some trouble figuring out why this function will not fully initialize a pointer in the main via a function. Here's an example of what I'm trying to do.#include <iostream>...
-2
votes
0answers
82 views

Problem of heap memory in C++ after generating random number

I have been struggling to run a genetic algorithm; however currently there is an issue when I want to generator random number. I use the one here.I have written it as follows:#include "stdafx.h"#...
0
votes
1answer
75 views

Deleting from Indexed Priority Queue (java)

I have an Indexed Minimum Priority Queue implemented as a heap. When deleting an indexed element, the code is:public void delete(int i) {if (i < 0 || i >=maxN) throw new ...
0
votes
1answer
63 views

How to use ArrayList in heapsort

I'm trying to implement heapsort using ArrayList. I'm not familiar with using ArrayList, but here is what I came up with for one method of my program, maxHeap:I'm not sure if I'm making use of the ...
-2
votes
0answers
48 views

implement min binary heap with deleting min [on hold]

I'm trying to implement binary heap using c++ and it's working but there is an issue I don't understand why it's happening. The last index value became 0 where I try to swap the last element in the ...
-1
votes
0answers
38 views

Store object (ArrayList) on the disk

I have a technical question concerning Java.I have limited RAM and my maximum heap is about 500 Mb.When I create a lot of objects (with another objects inside), my heap is over sizing and my JVM ...
0
votes
0answers
13 views

Inserting in Max heap with Key_Class as in parameter

I have to make my insert function follow the logic for a Max heap with a Key_Class as in parameter. So I actually have 2 questions.What is this Key_Class and how do I access the values inside it for ...
0
votes
1answer
32 views

MinHeap Delete Understanding

I am having difficulty in understanding the solutions of one of the problems my professor gave me regarding heaps. Give pseudocode for the routine Min-Heap-Delete(A, k). Assume that key k is at ...
1
vote
2answers
68 views

Performance benefit of using buffer on heap over stack (C)

I have a small buffer of 1024 bytes that I am using to store temporary data in and then write to a larger buffer. I am reusing that small buffer several times.Is there any performance benefit to ...
-2
votes
1answer
25 views

Insert function in maxHeap has unwanted behavior

have an insert function that should insert an element into the heap.public void insert(int element) {Heap[++this.size]=element;int i=this.size;while (Heap[i] > Heap[parent(i)]) ...
0
votes
0answers
24 views

Finding second and third smallest values in a Min-Heap [duplicate]

Is this logic correct?In an efficient minimum heap implemented with an array, it is O(1) to find the smallest value, because it is just the top-most element (the first element of the array. It is ...
1
vote
1answer
23 views

Stack and heap memory when array is initialized in java [duplicate]

I have a question about where in memory arrays are stored when arrays are initialized.I understand that local variables and method parameters are stored in stack; objects are stored in heap.What I ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,