Click here to Skip to main content
14,664,409 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am really confused about which is the mostly used data structure for a Heap ?
Most of answers I got were Arrays and Linkedlist , but other than that too what other options do we have ?

What I have tried:

Tried google but didnt got the required answer for my query .
Posted
Updated 4-Sep-20 9:43am
Comments
Richard MacCutchan 3-Sep-20 7:37am
   
As the other Richard already suggested, get a book on programming. Your confusion arises because you have not learned the basics. And until you do, no amount of questions here is going to help you.

Rate this:
Please Sign up or sign in to vote.

Solution 1

If you are talking about implementing a Heap, then pretty much all you will need is arrays and linked lists - normally the just latter to describe the free and allocated blocks as an array is limited by its initial size and that's unlikely to be helpful in a "real world" app.

If you are talking about "what goes on the heap in Java?" then that's a different question, and the answer is "everything, pretty much". The only things that don't are local variables such as primitives (integers for example) and references to heap based objects - all of these stack based objects are transitory as they will be deallocated automatically when the method they are local to exits.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Quote:
Tried google but didnt got the required answer for my query .

and we are supposed to guess what is you required answer?
Quote:
Which data structure is used to implement heap ?

May be a heap is a data structure by itself: Heap (data structure) - Wikipedia[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100