11-24-2002, 08:16 AM
I'm writing a Heap implementation using an array. I'm having trouble writing the sorting part of it, such as inserting items into a heap and sorting them max term on top and also min term on top. Can anybody help?
if so I'll post the code i've written so far.
(u might be wondering why I'm implementing a heap code, it's for class =)
11-24-2002, 03:46 PM
We will not write the code for you as this is a school assignment. I remember all too well how much fun (not) those were to write in my computer science courses at college.
Just think about how the algorith works then think what you need to do to accomplish it.
Then if you have a question on how to something in the language you are using then ask a specific question about the language.
Think about writing a trickleup() method. When you add an item to the heap, trickleup() it. This should just keep swapping it up until it shouldn't any longer.
Your teacher should have went over stuff like that in class...