Can anyone tell me how i can make a function that takes an Array and sorts it with the heap sort?
Can anyone tell me how i can make a function that takes an Array and sorts it with the heap sort?
I think that you should start a new thread for that. Furthermore, you should make an attempt before asking.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I have made many attempts... Because i am not sending my attempt (code) that's not mean that i haven't done anything and i want from you to solve it for me, i just want you if you can to explain me how the heap sort is because it's little bit confusing and i thing there are lots of ways to make a heap sorting of an array!!!
Last edited by ValL; 11-29-2012 at 10:06 AM.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
That's not really what I've had in mind.
With your version you can only write the array to the file the first time. For the second time (writing out the heap sorted array) you would still need a second function.
I would write the function in a way that you can use it for both writing operations. The main program would then look like
In general a function should do one particular thing.Code:create_array(array, n); first_file = fopen(...); write_array(first_file, array, n); sort_array(array, n); second_file = fopen(...); write_array(second_file, array, n);
Your function is calculating random numbers, assigns them to the array (and assumes that the first element is already written to the file), writes them to the file and prints them to the screen. Thus you can't use it in another part of your program because it is too specific.
Bye, Andreas
Hi, can anyone tell my how i can create an empty priority queue with doubly link lists? I can not understand how i must do it.
Last edited by ValL; 12-04-2012 at 08:09 AM.
Nice help!!! Thank you
That's wonderful. Now can we finally let this thread die? Thanks.
Can you just say anything (small help) about what i have asked and do not tell me every time i ask something, to give you evidence for my attempts i have done? Is that difficult to you? Or maybe you can't just get over it that here i am not to copy anything and just paste it in my exercise so i will be done? Is just a simple thing. Say a few words of what i have asked and don't delve into everything i said to find a problem. There is not any problem my friend!! Thank you.
P.S : And yes you can finally let this thread die...
No. Forcing you to come up with your own solutions makes you a good programmer.
If you just want to look at code that does what you want, use Google. You may say, "I don't want to just Google the answer, I want to learn how to program". There is no difference in getting code from us and Google.
"Give a man a fish and he feeds that night; teach a man to fish and he feeds for life"
Fact - Beethoven wrote his first symphony in C
You still do not understand me... I do not want code neither from you or Google. I just want a small help, like we say mmm, the priority queue does that (and don't explain it like an encyclopedia), and you should make a function which checks that...(only 2 lines of explaining, not much). Is not that difficult. Not code and not much words.
Thank you again!!!
you dont want much do you.and don't explain it like an encyclopedia), and you should make a function which checks that...(only 2 lines of explaining, not much). Is not that difficult. Not code and not much words.
Thought for the day:FLTK: "The most fun you can have with your clothes on.""Are you sure your sanity chip is fully screwed in sir?" (Kryten)
Stroustrup:
"If I had thought of it and had some marketing sense every computer and just about any gadget would have had a little 'C++ Inside' sticker on it'"
Is that enough for you to go on? Try to understand and implement as best you can. If/when you get stuck or have further questions, create a new thread and clearly describe the problems you're getting or questions you have.Originally Posted by http://en.wikipedia.org/wiki/Priority_queue
Hopefully, this thread will be closed to prevent further ignoring the moderators advice to start a new thread.