![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2005
Posts: 2
Rep Power: 0
![]() |
Queue. Array vs Linked List
Hey I was wondering what anyone would recommend? An array or Linked List for implementing a queue.... which performs better and which is easier to implement? Thanks
|
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: here
Posts: 137
Rep Power: 0
![]() |
It doesnt really matter. (I might catch heat for that).
Whatever you are comfortable with is what you should use. If you want to limit the number of items in the queue an array of fixed size might make things a little easier with pointers an modulus division, but the same can be accomplished with a linked list and a count variable. Of course inserting into the middle of a linked list is easier than doing so in an array. I mention that because you dont exclude priority queue in your post and insertions into a priority queue dont always fall at the beginning or end. What is your application? What are the requirements?
__________________
"...and though our kids are blessed their parents let them shoulder all the blame." - The Quiet Things That No One Ever Knows [BrandNew] |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Generally speaking, a linked list is best for a queue. An array has the disadvantage of being a fixed length; a linked list will take up less memory and can expand to any length your RAM can hold.
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
Link list hands down.... you will have more flexibility.
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 | |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: here
Posts: 137
Rep Power: 0
![]() |
Quote:
__________________
"...and though our kids are blessed their parents let them shoulder all the blame." - The Quiet Things That No One Ever Knows [BrandNew] |
|
|
|
|
|
|
#6 | |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Quote:
|
|
|
|
|
|
|
#7 | |
|
Professional Programmer
Join Date: May 2005
Location: Bad Nauheim, Germany
Posts: 436
Rep Power: 4
![]() |
Quote:
__________________
-Steven "Is this a piece of your brain?" - Basil Fawlty |
|
|
|
|
|
|
#8 | |
|
Expert Programmer
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#9 | |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: here
Posts: 137
Rep Power: 0
![]() |
Quote:
I made no claims about it being the fastest or best method, I was only pointing out that it could be done. ![]()
__________________
"...and though our kids are blessed their parents let them shoulder all the blame." - The Quiet Things That No One Ever Knows [BrandNew] |
|
|
|
|
|
|
#10 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5
![]() |
for dynamic sorting and greater flexibility the linked list is definately the way to go.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|