sandbox/ods/notes/chapter2.txt

22 lines
705 B
Plaintext
Raw Normal View History

# Chapter 2 (Array-based lists)
These data structures have common advantages and limitations:
* constant-time access
* resizing the array adds potentially non-trivial complexity, both in time and
storage, as a new array generally must be created and the old array copied
over.
* arrays aren't dynamic, which means inserting or deleting in the middle of an
array requires shifting all the following elements.
With some careful management, the additional *amortised* complexity added by
2018-02-08 16:38:06 +00:00
resizing isn't too bad.
## Array stack
* Uses backing array *a*.
* Typically, the array will be larger than necessary, so an element *n* is
used to track the actual number of elements stored in the stack.