Results 1 to 5 of 5
  1. #1
    lsk
    lsk is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default 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)
    Someone have an advice?
    thank you in advance

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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. #3
    lsk
    lsk is offline Member
    Join Date
    Jun 2011
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    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. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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. #5
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,732
    Blog Entries
    7
    Rep Power
    21

    Default

    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
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. priority
    By simorgh in forum Threads and Synchronization
    Replies: 4
    Last Post: 01-07-2012, 01:49 AM
  2. Priority Queue
    By Suende in forum New To Java
    Replies: 19
    Last Post: 04-25-2011, 09:46 AM
  3. Priority Queue experts needed !!!
    By niu_niu in forum New To Java
    Replies: 48
    Last Post: 06-11-2010, 09:48 AM
  4. Priority Queue Question
    By Taz_84 in forum New To Java
    Replies: 0
    Last Post: 01-29-2009, 04:23 AM
  5. How to implement Priority queue with Java
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-12-2008, 09:49 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •