Heap Sorting...

weeshen

Member
Joined
Oct 1, 2006
Messages
13
Programming Experience
Beginner
Hey guys, its crunch time again and i have an assignment due next wednesday and don't have a clue on how to do this or where to start. I learned what heap sorting is and what it does except that i have a problem. The book that was used to teach me this does not give nearly enough code for what i need to do which is to heap sort 10 random integers. If somebody can give me all the code that is necessary to do this it would be GREATLY GREATLY appreciated.
 
Your heap sorting in a Visual Basic class?

Or, do you mean, simply take a given list of 10 integers and sort them low to high (or high to low)?
 
Your heap sorting in a Visual Basic class?

Or, do you mean, simply take a given list of 10 integers and sort them low to high (or high to low)?

My knowledge is that there is some code that does a heap sort in vb.net that sorts any amount of numbers (from low to high) but the code for heap sort is very interesting and this is the closest thing i could find to what i am looking for but don't know how to implement it for any random 10 integers from 0-99....http://www.source-code.biz/snippets/vbasic/6.htm
 
The heap sort is an algorithm, just like any type of sorting, and the point of your class for you to implement that algorithm in VB.NET. That's your assignment and you're asking us to give you ALL the code that is necessary? Then we would be doing your homework for you and that's not what this forum is for. That would be against forum rules and you would be committing academic misconduct. I suggest that you make an effort to start and if you have specific questions about issues you're having along the way then ask them but we're not here to help you cheat.

The key to any programming problem is to divide an conquer: you break the problem up into smaller problems and when you've solved each sub-problem you have inherently solved the overall problem. For instance, if there's a point in the algorithm that requires that you swap the position of two objects then you write a routine that will perform that function. Now you don't have to worry about that bit because each time you need to swap two objects you just call that routine.

Another thing is that you shouldn't even be thinking about code at this point because you obviously have no idea where you're going. You should only be at the pen and paper stage. You should be writing the algorithm out, step by step, on paper. Then you can get an understanding of how it works and how it can be broken down. The next step is to write out again on paper in pseudo-code. Only when you've got satisfactory pseudo-code should you even think about opening the IDE and writing VB code. To go straight from an idea to working code is lazy and will ultimately take more time. How can you solve a problem that you don't understand? The proper steps of software development will help you gain that understanding. If you expect to be able to take shortcuts then the results are predictable.
 
Back
Top