Please note that you've posted your question in the "Meaningless Drivel" forum - this is the forum on the website here where we make jokes and relax. If you post in here, expect to get non-serious answers. We have many other forums where your question will be taken more seriously.
I assume that you are looking for serious answers to your question, so I'll move it to a more appropriate forum. Please select an appropriate forum yourself, next time when you post a question.
Personally, I find the question rather vague..."pseudo-code" means "in English (or any other natural language)". And a "heap data structure" is an abstraction of a concept.
So you are asking us to tell you in English how to put together an abstract thing.
I guess the first question is "Do you know what a heap data structure is?", quickly followed by "do you know what a max heap data structure is"?
At the most basic level, the pseudo-code would be something like
1) create an empty heap
2) call 'insert' for each element you want to insert.
Did you have some other, more specific question? are you trying to write your own heap? are you trying to create the EXACT heap you show in your original post?or are you trying to do something else?
Never ascribe to malice that which can be adequately explained by stupidity.
ethio roln
Greenhorn
Joined: Jun 24, 2012
Posts: 2
posted
0
Jesper de Jong wrote:Welcome to the Ranch, ethio roln.
Please note that you've posted your question in the "Meaningless Drivel" forum - this is the forum on the website here where we make jokes and relax. If you post in here, expect to get non-serious answers. We have many other forums where your question will be taken more seriously.
I assume that you are looking for serious answers to your question, so I'll move it to a more appropriate forum. Please select an appropriate forum yourself, next time when you post a question.
Thank you for that.
fred rosenberger wrote:Personally, I find the question rather vague..."pseudo-code" means "in English (or any other natural language)". And a "heap data structure" is an abstraction of a concept.
So you are asking us to tell you in English how to put together an abstract thing.
I guess the first question is "Do you know what a heap data structure is?", quickly followed by "do you know what a max heap data structure is"?
At the most basic level, the pseudo-code would be something like
1) create an empty heap
2) call 'insert' for each element you want to insert.
Did you have some other, more specific question? are you trying to write your own heap? are you trying to create the EXACT heap you show in your original post?or are you trying to do something else?
I know what a heap is and how it works. This is for a course work I did and got no marks for this question.
"Describe in pseudo-code the Initialisation of the data structure as of figure (a).
Ignore node 95, which is about to be inserted."
well...I don't think you need to specify the size. Heaps should grow as needed.
then you need to start inserting the values so that you get the structure in the diagram. I believe you'd insert 82 first, so that it becomes your root.
I'm not sure how you'd insert the rest of the elements. According to the wikipedia, new elements are generally inserted at the first open node. This often 'breaks' the heap properties, so it must then be 're-heapified'. I'm not sure how you'd force it to end up in the exact configuration specified since the implementation of the re-heapify is usually a mystery.
If this is course work, I'd suggest you talk to your professor/TA about what THEY think the correct answer is.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: How do you initialise a heap data structure using pseudocode