# Thread: Priority Queue with explicit priority

1. Member
Join Date
Jun 2011
Posts
3
Rep Power
0

## 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)

2. 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.

3. Member
Join Date
Jun 2011
Posts
3
Rep Power
0
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)
Last edited by lsk; 06-10-2011 at 07:54 PM.

4. 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.

5. 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