Contiguous and Linked Implementations
Contiguous and Linked Implementations
- Contiguous implementations of lists (and stacks and queues) use a fixed-size block of memory for entries
- Advantages: simple to implement, fast running, little variability in time needed for adding and removing elements
- Disadvantages: unused entries still occupy space, number of entries limited to array size, insertion at “other” end or middle is costly
- Linked implementations allow list (or stack or queue) elements to be in scattered memory locations
- Entries are usually allocated on the heap
- Advantages: number of entries limited only by available memory, unused entries don’t occupy space, insert anywhere is efficient
- Disadvantages: memory allocation may be slow and take variable time, harder to implement
- But: special-purpose allocation strategies have been developed for time-critical systems
CMPS012B Spring '97 pages maintained by
Mike Goss <goss@cse.ucsc.edu>