# Priority Queue with explicit priority

• 06-10-2011, 06:42 PM
lsk
Priority Queue with explicit priority
Hello, this is my first post.
I'm currenty implementing, for an university project a priority queue, to be used with the dijkstra algorithm. For the project the queque must have only this public methods:

• creation of an empty code, specifying the length
•  isEmpty() checks if the queue is empty

• add(u,d) inserts a node u with priority d

• deleteMin() returns (and deletes from the queue)the node with minumum distance
•  changePriority(u,d) changes the priority of u with d

all the literature I've found uses only a variable to add an element to the queue, so I'm quite stuck. (ok, maybe I'm only dumb and I cannot adapt it to my case)
• 06-10-2011, 06:48 PM
Norm
Quote:

uses only a variable to add an element to the queue
Can you explain what that means?
I have no idea about the algorithm you are working on. I'll leave that to you to define it. I work mostly on java programming.
• 06-10-2011, 06:51 PM
lsk
Quote:

Originally Posted by Norm
Can you explain what that means?
I have no idea about the algorithm you are working on. I'll leave that to you to define it. I work mostly on java programming.

oh, sorry. I'm implementing a priority queue, like this one or this one or the one quoted here. in every Example I've fond the "priority" is implicit in the input I give. I need instead to define the priority of an element into the add method (so I must use a couple of object instead of only one)
• 06-10-2011, 06:55 PM
Norm
Sorry, I'll leave the algorithm research to you. When you get a design and are having problems writing it in java, come on back.
• 06-10-2011, 07:16 PM
JosAH
As far as I know the Dijkstra algoritm the 'priority' is defined as the path length; if you insert path objects in your priority queue you can use an ordinary TreeSet<Path> for it; no problem.

kind regards,

Jos