priority queue implementation?

Started by
15 comments, last by GekkoCube 20 years, 7 months ago
quote:Original post by GekkoCube
"Why search when you can keep it in the class?"

- Huh? I dont follow.


I think he was confused.
Advertisement
how do you make those horizontal lines to "repost" a quote from somebody else?
well,, going back to the whole priority queue & heap thing...

I was wondering if I should implement a heap that is pointer-based or array-based.

what would be the benefits and disadvantages of each?
ok, i made up my mind...im going to write a heap that is represented by an array.

but i still have a question regarding even this!

Would it be quite alright with respect to speed and efficiency if i used a dynamically resizeable array, like a vector???
quote:second, is there pseudocode to sort a tree for the max/min key in the tree? because my data structures textbook sure doesnt offer any.

I was saying you don''t need to search, you can just keep track of the min/max as you insert it into your class.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
you are saying that the min/max does not need to be at the top, or in my array-based case, at index 0?

i dont think this will work. i COULD leave everything unsorted and simply remove the element with the smallest/largest key.

but that would still mean sorting it at some point in time so that if a new element is inserted it''s key must be checked with others.
I think what antareus was saying is that if you sort your tree, then you don't have to search at all because the highest priority item will always be in the same place.

[edited by - Martel on September 4, 2003 12:58:33 AM]

This topic is closed to new replies.

Advertisement