DSA, Database System & Operating System β Data Structure, Lists, Linked Lists and Trees, NEC licence examination syllabus (Nepal Engineering Council).
Fixed size vs growing size β a decision that ripples through your whole program's design.
StaticFixed size decided at creation (like a plain array) β fast access, but wastes space if underused, or fails if you need more than allocated.
DynamicGrows/shrinks as needed (like a linked list, or a dynamically resizing array) β flexible, at the cost of some extra overhead per element.
A dynamically resizing array does not grow one element at a time β that would be ruinous. When it fills, it allocates a larger block, typically double, and copies everything across.
A single one of those copies costs O(n), which looks alarming. But because the capacity doubles each time, the copies get rarer as the array grows, and the cost averaged over all insertions works out to O(1) each. This is called amortised constant time, and the word is doing real work: any individual insertion may be slow, while the average stays fast.Known sizeStatic wins β no resize logic, no wasted capacity, no pointer overhead.
Unpredictable sizeDynamic, or a static structure sized for the worst case if that is knowable and affordable.
Access patternFrequent random access favours contiguous arrays; frequent insertion in the middle favours linked structures.
PredictabilityStatic gives consistent timing. Dynamic gives a good average with occasional spikes.
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Loadingβ¦