Re: How does a linked-list optimize a stack ?
- From: Tim Roberts <timr@xxxxxxxxx>
- Date: Mon, 24 Sep 2007 21:38:11 -0700
Jeff?Relf <Jeff_Relf@xxxxxxxxx> wrote:
Are you ( Mr. Voigt ) telling me Jack is using a linked-list
because he needs a ? queue or stack ? ? I can't tell what Jack wants.
How does a linked-list optimize a stack,
? blowing sorted arrays out of the water ? ?
A sorted array is by nature of fixed size. When the stack fills it, you
have to allocate a bigger chunk and copy the old data. With a linked list,
you just keep adding items on the end.
If you know a maximum upper bound for the stack size, then an array is
better.
Is it like several seconds faster for very large stacks ?
"Several seconds faster" is not a particularly meaningful measure. If you
do billions of pushes and pops, a few cycles here and there makes a pretty
big difference.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.
- Follow-Ups:
- Linked-lists don't make sense.
- From: Jeff☠Relf
- Linked-lists don't make sense.
- References:
- [OT] Some open-source header files
- From: Jack
- Re: [OT] Some open-source header files
- From: Ulrich Eckhardt
- Re: [OT] Some open-source header files
- From: Jack
- I suggest binary searches not “ linklist.h ”.
- From: Jeff☠Relf
- Re: I suggest binary searches not " linklist.h ".
- From: Ben Voigt [C++ MVP]
- How does a linked-list optimize a stack ?
- From: Jeff☠Relf
- [OT] Some open-source header files
- Prev by Date: How does a linked-list optimize a stack ?
- Next by Date: Linked-lists don't make sense.
- Previous by thread: How does a linked-list optimize a stack ?
- Next by thread: Linked-lists don't make sense.
- Index(es):
Relevant Pages
|
|