Results 1 to 7 of 7
  1. #1
    sick_peng is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default linked list or array?

    hey im new to the site =) but i just had a question that i asked one of my teachers aid's in class and they wern't able to assist me, i was hoping someone on here might have a better understanding.

    we've been talking about queue's in class, and to my understanding a linked list works great just because of how it is structured. but what about an array? i mean yeah an array itself seems like a not so logical way to go about a queue. i read that circular arrays can work just as well.. are there times when you should use a circular array queue over a linked list queue? what is the real difference between the two?? what i was thinking is that it would be easier to find a specific "thing" in a circular array queue acting like a "priority queue" if that makes sense.

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    the difference between a queue using a circular array and linked list is the same as just using an array vs a linked list in most situations, really.

    also, a priority queue doesn't work with a single array or list. depending on its actual specs, it can be composed of 2 or more queues, one for each level of priority. sure, you can define one where it uses a single list, but it would be inefficient to have to iterate through it, as opposed to taking advantage of a queue being fifo.

  3. #3
    sick_peng is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    true but, if you arrange the array in a circular fashion can't you make it so instead of iterating through everything you can just change what index denotes the head and the tail of the queue??

    ex.

    array has object at index 1-5;
    queue is identified for objects 1-5:

    object 1 is removed from queue;
    queue is redifined;

    array has object at index 1-5;
    queue is identified for objects 2-5;

    thats kinda what was going through my head....
    Last edited by sick_peng; 04-15-2009 at 07:42 PM.

  4. #4
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    are you still talking about a priority queue?

  5. #5
    sick_peng is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    no a priority queue was just something that i thought that maybe an array could be used over a linked list. my question is... is there "ANY" reason or situation where a circular array would be more useful thank a linked list used in any type of queue
    Last edited by sick_peng; 04-15-2009 at 08:15 PM.

  6. #6
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    and to that i replied that the dis/advantages of each are similar to general uses of arrays and linked lists. unless you're implying that there is no reason to ever use an array.

  7. #7
    sick_peng is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    aight naw i was just curious guess idk what kind of an answer im looking for haha.. anyway thanks for replying man.

Similar Threads

  1. Linked list
    By rosh72851 in forum New To Java
    Replies: 1
    Last Post: 02-05-2009, 08:21 AM
  2. Linked List integer list
    By igniteflow in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 09:53 PM
  3. Linked List help
    By neobie in forum New To Java
    Replies: 8
    Last Post: 12-22-2007, 04:15 AM
  4. Linked List
    By rnavarro9 in forum New To Java
    Replies: 0
    Last Post: 11-29-2007, 04:42 AM
  5. Help with linked list
    By trill in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 08:29 AM

Posting Permissions

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