clarification on Heaps please!

T

Totti

hi all,
i am using Robert Lafore's book to learn JAVA, which i hope, you are
familiar with.
at any rate, in chapter 12 he is talking about HEAPS and he has the
code of making a heap of numbers, but since there are two kinds of
heaps Min and Max, the code covers only the Max which has the Parent
bigger than the children, so i am thinking of how could i change his
code to make it produce a minimun heap?
that is if you are familiar with the book, if you are not, would you
please give me some general info on how this thing works and what
should be altered to make it work otherwise i mean from max to min

any help appreciated and thanks in advance.
 
D

Daniel Pitts

Totti said:
hi all,
i am using Robert Lafore's book to learn JAVA, which i hope, you are
familiar with.
at any rate, in chapter 12 he is talking about HEAPS and he has the
code of making a heap of numbers, but since there are two kinds of
heaps Min and Max, the code covers only the Max which has the Parent
bigger than the children, so i am thinking of how could i change his
code to make it produce a minimun heap?
that is if you are familiar with the book, if you are not, would you
please give me some general info on how this thing works and what
should be altered to make it work otherwise i mean from max to min

any help appreciated and thanks in advance.
Heaps aren't specific to Java.

Changing a between a min-heap and a max-heap is as simple as reversing
the "<" to a ">" where appropriate.
 
L

Lew

Totti said:
i [sic] am using Robert Lafore's book to learn JAVA, which i hope, you are
familiar with.
at any rate, in chapter 12 he is talking about HEAPS and he has the
code of making a heap of numbers, but since there are two kinds of
heaps Min and Max, the code covers only the Max which has the Parent
bigger than the children, so i am thinking of how could i change his
code to make it produce a minimun heap?
that is if you are familiar with the book, if you are not, would you
please give me some general info on how this thing works and what
should be altered to make it work otherwise i mean from max to min

Daniel said:
Heaps aren't specific to Java.

Changing a between a min-heap and a max-heap is as simple as reversing
the "<" to a ">" where appropriate.

Was it in this thread that someone recently recommended
<http://bcs.wiley.com/he-bcs/Books?a...ssetId=110292&resourceId=10137&newwindow=true>

which has a very thorough, engaging and Java-centric discussion of heaps and
heapsort in that free chapter?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top