🧮Dynamic Array
Also known as Resizable Array, Growable Array, ArrayList, Vector (C++)
An array that grows. When it is full, it moves to a bigger block.
Think of it like
It is like a family moving to a bigger house when the old one fills up. They pack, move, and have space to spare.
Example
Lucy appends 10,000 scores to a Python list. Now and then the list moves to a bigger block, but each append still feels instant.
Why it matters
It gives you fast reading by position and room to grow. That is why it is the default list in most languages.
Definition
Example code
python
scores = []
for s in [90, 75, 88]:
scores.append(s)
print(scores[1])
# 75Common mistake
Key takeaways
- 1Side by side. Fast to read any position.
- 2Grows by copying. Moves to a bigger block when full.
- 3Fast on average. The copy happens rarely.