---
title: "Array list; static or dynamic choice"
subject: "Data Structure and Algorithm"
chapter: 3
key: "semester_4/data_structure_and_algorithm:array-list-static-dynamic-reason"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/array-list-static-dynamic-reason
site: BCT Engineering
---

# Array list; static or dynamic choice

Data Structure and Algorithm · Chapter 3: List

- Asked in: 2070 Bhadra, 3+3 marks
- Video: [Arrays vs Linked Lists - Data Structures and Algorithms](https://www.youtube.com/watch?v=dMy2hq9OUMc) — Caleb Curry
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/array-list-static-dynamic-reason
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-3

## Question

Explain array implementation of list. State the reason why would you choose either static implementation or dynamic implementation for list.

## Short answer

Array implementation stores elements in consecutive locations with a count n, giving O(1) access and O(n) insert/delete due to shifting. Choose static when maximum size is known and random access is important; choose dynamic linked list when size varies and many insertions/deletions occur.

## Answer

#### Array implementation of a list

A list is a linear sequence of elements. In array (static) implementation the elements occupy **consecutive locations** of an array `LA[0..MAX-1]`, and an integer `n` counts the elements in use. The position of an element gives the order.

```text
index:   0    1    2    3    4 ...  MAX-1
       | 10 | 20 | 30 | 40 |    | ...  |      n = 4
```

- Access to the i-th element: `LA[i]`, O(1).
- Insert at k: shift `LA[k..n-1]` right, store item, `n++`. O(n).
- Delete at k: shift `LA[k+1..n-1]` left, `n--`. O(n).
- Overflow when `n == MAX`; underflow when `n == 0`.

```c
#define MAX 100
int la[MAX], n = 0;
void insert(int k, int item) {          /* 0 <= k <= n */
    if (n == MAX) { printf("Overflow\n"); return; }
    for (int j = n - 1; j >= k; j--) la[j + 1] = la[j];
    la[k] = item;  n++;
}
```

#### Choosing static or dynamic implementation

| Choose static (array) when | Choose dynamic (linked list) when |
|---|---|
| Maximum size is known in advance | Size is unknown or varies a lot |
| Fast random access is needed | Access is mostly sequential |
| Few insertions/deletions in the middle | Many insertions/deletions |
| Memory per element must be small (no pointers) | Extra pointer memory is acceptable |
| Simple code is preferred | Flexible memory use is preferred |

For example, a list of the 12 months is best kept in an array (fixed size, indexed access), while a waiting list of customers whose number changes constantly is best kept as a linked list.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. In array implementation, what does n represent?
   A. Array capacity
   B. Number of elements in use
   C. Index of the last cell
   D. Number of free cells
   Answer: B. n counts the elements currently stored. (Key point: Array list representation)

2. Why is inserting at position k in an array list O(n)?
   A. Search is needed
   B. LA[k..n-1] must be shifted right
   C. A node is allocated
   D. Sorting is needed
   Answer: B. Elements from k onward shift one place. (Key point: Insert cost)

3. When does overflow occur in an array list?
   A. n == 0
   B. n == MAX
   C. k == 0
   D. n == 1
   Answer: B. No free cell remains when n equals capacity. (Key point: Overflow condition)

4. Which fits an array best?
   A. Waiting list of customers
   B. List of the 12 months
   C. Unknown number of records
   D. Frequent middle insertions
   Answer: B. The size is fixed and indexed access is needed. (Key point: Choice example)

## Related in Data Structure and Algorithm

- [Why choose static or dynamic list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Achoose-static-or-dynamic-list) — Data Structure and Algorithm, chapter 3
- [Static and dynamic data structures; array list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Astatic-dynamic-ds-array-list) — Data Structure and Algorithm, chapter 3
- [Static vs dynamic implementation of list](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Astatic-vs-dynamic-list-example) — Data Structure and Algorithm, chapter 3, asked 2×
- [Static vs dynamic implementation of stack](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Astack-static-vs-dynamic) — Data Structure and Algorithm, chapter 2
- [Array implementation of list in C](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aarray-list-c-limitations) — Data Structure and Algorithm, chapter 3
- [Dynamic implementation of queue](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Adynamic-queue-linked-algorithm) — Data Structure and Algorithm, chapter 4

## Related in other subjects

- [Static and dynamic hazards and their elimination](https://www.bctengineer.com/question.md?key=semester_3%2Fdigital_logic%3Astatic-dynamic-hazards) — Digital Logic, chapter 3, asked 2×
- [Dynamic memory for object and object array](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Adynamic-memory-object-array) — Object Oriented Programming, chapter 3
- [Static vs dynamic mathematical model](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Astatic-vs-dynamic-math-model) — Simulation and Modeling, chapter 2, asked 3×
- [Static versus dynamic binding trade-offs](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Astatic-vs-dynamic-binding) — Object Oriented Programming, chapter 7
