hi,
Somebody please tell me diff between vector and linked list ? When to use which ? URGENT.
Thanx,
viji
-
vector vs Linked list (7 messages)
- Posted by: viji v
- Posted on: November 14 2000 11:34 EST
Threaded Messages (7)
- vector vs Linked list by Chiew Lee on November 14 2000 11:57 EST
- vector vs Linked list by Gary Silverman on November 15 2000 15:57 EST
-
vector vs Linked list by Dave Wolf on November 16 2000 02:48 EST
-
vector vs Linked list by matt heaton on November 17 2000 02:01 EST
-
vector vs Linked list by John Kelvie on December 25 2000 08:42 EST
- vector vs Linked list by Vikrant Korde on January 12 2005 04:27 EST
-
vector vs Linked list by John Kelvie on December 25 2000 08:42 EST
-
vector vs Linked list by matt heaton on November 17 2000 02:01 EST
-
vector vs Linked list by Dave Wolf on November 16 2000 02:48 EST
- Re: vector vs Linked list by Internet Citizen on September 04 2008 21:58 EDT
- vector vs Linked list by Gary Silverman on November 15 2000 15:57 EST
-
vector vs Linked list[ Go to top ]
- Posted by: Chiew Lee
- Posted on: November 14 2000 11:57 EST
- in response to viji v
A vector is a growable array. u can store any object derived from the object class) to it.
A linked list is a list where each item in the list have a link to the next item. u can use linked-list to implement queue or stack.
BTW, such answer can be easily found from any comp science text book or from the internet itself. i strongly believe that u should not post such question in this column.
HTH.
alex
-
vector vs Linked list[ Go to top ]
- Posted by: Gary Silverman
- Posted on: November 15 2000 15:57 EST
- in response to Chiew Lee
Actually, a question _like_ this may be very valid for this forum if the reason it's being asked has to do with performance. I do not believe the original question is being asked for this reason, and as such I agree with you.
I would like to point out that with respect to performance, the decision on which to use may be very relevant.
As per the javadoc, which you should look at before posting your question, the LinkedList is not sychronized, but Vector is. This has performance and behaviour implications.
I advise the poster to check the docs, and refer to the source code if necessary.
My 2 cents... -
vector vs Linked list[ Go to top ]
- Posted by: Dave Wolf
- Posted on: November 16 2000 14:48 EST
- in response to Gary Silverman
Its an even bigger issue when you look at the cost of marshalling that Vector. Vector can be an incredibly expensive object to serialize.
Dave Wolf
Internet Applications Division
Sybase
-
vector vs Linked list[ Go to top ]
- Posted by: matt heaton
- Posted on: November 17 2000 14:01 EST
- in response to Dave Wolf
If you don't want the synchronization overhead of a Vector use and ArrayList, they pretty much have the exact same function just ArrayList isn't synchronized. -
vector vs Linked list[ Go to top ]
- Posted by: John Kelvie
- Posted on: December 25 2000 20:42 EST
- in response to matt heaton
First, I would recommend picking up the book Practical Java. It has excellent tips that cover this area, and my subsequent comments come from tips I gleaned from that book.
Anyway, as a general rule, prefer an ArrayList to a Vector or LinkedList. The ArrayList is essentially a unsynchronized Vector, making it faster. If you need synchronization, obviously, it is not such an obvious choice. As compared to the Linked List, I quote here from the Java API documentation:
"The add operation runs in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking). The constant factor is low compared to that for the LinkedList implementation."
Faster than any of these options, and perhaps therefore preferrable, is simple using an array. ArrayLists and Vector essentially amount to this, with some nice convenient add and remove features, among others. Nothing, though, really that can't be implemented easily with an array. The performance boon, supposedly, is something on the level of 17x. Not bad.
-
vector vs Linked list[ Go to top ]
- Posted by: Vikrant Korde
- Posted on: January 12 2005 04:27 EST
- in response to John Kelvie
hi John Kelvie,
Thanks for helping me in taking decision which is to be used. Actually i was in the middle of once performance tuning operation so just looking for the options.
What ever may be the aim of the initiator of this thread, vijji v, it helped me a lot.
Also thanks for suggeting a good book, i'll look for it if at all i can get it some where. -
Re: vector vs Linked list[ Go to top ]
- Posted by: Internet Citizen
- Posted on: September 04 2008 21:58 EDT
- in response to Chiew Lee
BTW, such answer can be easily found from any comp science text book or from the internet itself.This is the Internet! This page is one of the first results for "java vector versus list" on Google... And your response is not particularly helpful. Continuing on to other results...