heap

max heap and binary tree

Hi this is an example in my data structure book and for this exercise was written that this is not a max heap,but it doesn't say its reason would you please help me that why it is not a max heap thanks. 35 / \ / \ 27 28 / \ / \ / \ / \ 14 16 20 19 ...

Why does this Java/Groovy code cause heap memory exceptions?

Hi, This 3rd party script keeps causing heap memory exceptions: byte[] forwardMessage(byte[] content) { s = new Socket("172.17.0.30", 10001); s.withStreams {InputStream input, OutputStream output -> output.write content return readRtsData(input) } } byte[] readRtsData(input) { def vplEndByte = 0xff ...

about heap and deleting the i-th item

hi I want to write an algorithm that will delete the i-th item in the heap which has o(logn),also I want to know that the i-th element will be the less one item in the heap or no? is there any site that help me to write this algorithm? please help me thanks ...

what is the maximum heap size and stack size supported by iphone os?

Hi Could anyone tell me what is the maximum application size supported by iphone? Also what is the maximum heap size and stack size supported? Application goes 'out of memory' very soon... ...

heapq.nlargest index of returned result in original sequence

Hi everyone, How do I return the index in the original list of the nth largest items of an iterable heapq.nlargest(2, [100, 2, 400, 500, 400]) output = [(3,500), (2, 400)] This already cost me a couple hours. I can't figure it out. ...

Secondary Order in Heap::Simple

How do I define a secondary ordering to the Heap::Simple interface in Perl? ...

why use Heap Memory in Java

Why do we use Heap Memory, Can we use Stack memory for the same? EDITED One more question came in my mind after reading answers 1) is there any other kind of memory which we can think of alternative to Heap and Stack? Edited I came across the string pool, is that memory associated with the heap or Stack? ...

Why are heaps in c++ implemented as algorithms instead of containers?

I was wondering why the heap concept is implemented as algorithms (make_heap, pop_heap, push_heap, sort_heap) instead of a container. I am especially interested is some one's solution can also explain why set and map are containers instead of similar collections of algorithms (make_set add_set rm_set etc). ...

Heapsort in descending order not working

I have been looking at this for hours and can't figure this out. If the comparisons in the heapify function are changed to greater than, then the output is in increasing order as it should be. I want my list to be sorted in decreasing order though and it's not giving the correct output using the below code: #include <stdlib.h> #include ...

Using Any type element and key_insert to optimize insertion and secondary sort in Heap::Simple

Before, I had defined my elements entry as just Array in H::S because I did not need a secondary sort. After implementing a secondary sort and a function for defining the elements to insert array references into a heap I made, the runtime of my insertions increased (alot!). This is covered in the documentation for Heap::Simple under ht...

Secondary Keys with Heap::Simple in Perl

I wanted to investigate if anyone has ever used a secondary key when inserting into the Heap::Simple in Perl? If so, was your performance ever impacted? ...

casting from binary to multi-dimensional array on heap

i'm currently using binary files for quick access to custom objects stored in multidimensional arrays which are saved to file as object arrays. so far, reading from file hasn't been too much of a problem since i've been reading the array into an identical object array on the stack. it looks something like this: Foo foo[5][10]; ifstream ...

Do you know a tool for c++ program that shows which program line allocated how much heap?

Hi, I have a c++ program that dies because of out of memory error. Do you know a tool for c++ program that shows which program line allocated how much heap? I would like to figure which part of the program consumes most of the heap. Thanks. Platform: Microsoft C++...Windows By the way, can heap corruption cause excessive memory usage?...

is there any problem with this algorithm?

I have a problem with this algorithm for Heap-Sort Heap_Sort(A) Build_Heap(A) for i<--n down to 2 swap (A[1],A[n]) n<--n-1 MaxHeapify(A,1) I think instead of this algorithm we should write: Heap_Sort(A) Build_Heap(A) for i<-- n down to 1 Delete_Max(A) ...

MySQL Heap/Memory based table

I have a server with 12GB RAM, and max_heap_table_size in my.cnf is set to 6GB. ("max_heap_table_size=6442450944"). I restarted the MySQL server after setting this. The trouble is, whenever my table gets to just 2GB during inserts I get error "table full". Why is it not letting me add more than 2GB worth of data? (The 2GB figure is what...

Weblogic 10.3 managed server shared memory object(s)

We are using Oracle Weblogic 10.3 as our application server. We have multiple modules that need to access an Object (contains some HashMaps) that is common for the managed server. This object will be populated via some other process on a daily basis. We do not want to have copies of this in each application, due to the large number of...

C++: What does it mean to "new" a collection that will keep growing?

Hi all, I am new to C++. What does it mean exactly to "new" a collection? For example: UnicodeStringList* tmp = new UnicodeStringList; // where UnicodeStringList is typedef to std::list<UnicodeString> When you "new" something you have to know exactly how big you need it to be, right? So when I use the assignment constructor to c...

How do I modify the Min Heap insert and delete function to accept a second comparison if the primary comparison happens to be equal?

below I have a standard insert and delete function for a Min Heap, what I need to do is add a special case to both the functions when the T.num comparison happen to be equal, I then need to then compare the T.Letter where the lower Ascii value is popped first. Without the comments is the standard insert and delete, add the commented sect...

Java webstart max-heap-size causes JVM cannot be started

We use java webstart on the client side for a java swing based aplication. Recently we have been experiencing a weird "Cannot start java Virtual machine " error when clicking in the jnlp link. We soon find out its because the max-heap-size setting in the jnlp file was set to 1024m whereas most of the clients PC only have 1 gb physical ...

Java memory allocation on stack vs heap

I feel like a novice for asking this question -- but why is it that when I pass the Set below into my method and point it to a new HashSet, it still comes out as the EmptySet? Is it because local variables are allocated on the stack, and so my new is blown away when I exit the method? How could I achieve the functional equivalent? imp...