Re: Dynamic data structures
- From: pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
- Date: Sat, 26 Jul 2008 18:41:50 +0200
Roman Töngi <roman.toengi@xxxxxxxxxx> writes:
I've learned a strategy to resize the size of a data structure to
implement a dynamic data structure as follows:
E.g. for a stack:
- If the stack if full, create a new one with double of the old size.
[...]
With such a strategy (doubling if full and halving if count gets below 25%),
an amortized worst case analysis shows that the average cost per operation is
constant.
Are there better strategies?
In the case of a stack, you don't need to use one big block, you can
easily use a stack of small blocks.
Even for datastructure with other access mode (eg arrays with random
access), you can use this trick, adding just an indirection on each
access. See for example:
http://groups.google.com/group/comp.lang.lisp/msg/31dc2d17f972941c
--
__Pascal Bourguignon__ http://www.informatimago.com/
Kitty like plastic.
Confuses for litter box.
Don't leave tarp around.
.
- References:
- Dynamic data structures
- From: Roman Töngi
- Dynamic data structures
- Prev by Date: Dynamic data structures
- Next by Date: trees
- Previous by thread: Dynamic data structures
- Next by thread: Re: Dynamic data structures
- Index(es):
Relevant Pages
|