---
title: "Static vs dynamic implementation of list"
subject: "Data Structure and Algorithm"
chapter: 3
key: "semester_4/data_structure_and_algorithm:static-vs-dynamic-list-example"
source: https://www.bctengineer.com/q/semester_4/data_structure_and_algorithm/static-vs-dynamic-list-example
site: BCT Engineering
---

# Static vs dynamic implementation of list

Data Structure and Algorithm · Chapter 3: List

- Asked in: 2072 Asoj, 6 marks; 2071 Bhadra, 6 marks (asked 2 times)
- 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/static-vs-dynamic-list-example
- Whole chapter: https://www.bctengineer.com/md/semester_4/data_structure_and_algorithm/chapter-3

## Question

Differentiate between static and dynamic implementation of list with suitable example.

## Short answer

Static list (array) has fixed size, contiguous memory, O(1) index access, but insertion/deletion requires shifting elements O(n). Dynamic list (linked nodes) allocates memory at runtime, uses pointers, allows O(1) insertion/deletion after position is found, but sequential access O(n).

## Answer

A **list** is a linear collection of elements in a sequence. It can be implemented **statically** (array) or **dynamically** (linked nodes with pointers).

| Static implementation (array) | Dynamic implementation (linked list) |
|---|---|
| Elements stored in contiguous memory | Nodes stored anywhere; linked by pointers |
| Size fixed at compile time | Size changes at run time |
| Memory is allocated even if unused | Memory allocated only when a node is needed |
| Insertion/deletion in the middle needs shifting of elements: O(n) | Only pointers change once the position is known: O(1) |
| Random access by index: O(1) | Sequential access only: O(n) |
| No extra memory for links | Extra memory for the pointer in every node |
| Overflow when array is full | Overflow only when heap is exhausted |
| Memory freed only at program end | Memory returned with `free()` |

#### Example: list 10, 20, 30

Static:

```c
int list[100] = {10, 20, 30};   // n = 3
// insert 15 at index 1: shift 20, 30 right -> 10 15 20 30
```

Dynamic:

```c
struct node { int info; struct node *next; };
// head -> [10|*] -> [20|*] -> [30|NULL]
// insert 15 after 10: p->next = q->next; q->next = p;  (no shifting)
```

Choose arrays when the size is known and fast access is needed; choose linked lists when size varies and insertions/deletions are frequent.

## Check yourself

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

1. Why is inserting in the middle of an array list O(n)?
   A. Memory must be allocated
   B. Elements must be shifted
   C. Pointers must be freed
   D. The array must be sorted
   Answer: B. Later elements move one place right to make room. (Key point: Insertion cost)

2. Which has O(1) access by index?
   A. Linked list
   B. Array list
   C. Both
   D. Neither
   Answer: B. Contiguous storage allows direct addressing a[i]. (Key point: Random access)

3. In inserting 15 after 10 in the linked list, what changes?
   A. All nodes shift
   B. Only p->next = q->next; q->next = p
   C. The array is resized
   D. head is freed
   Answer: B. Only two pointers change, no shifting. (Key point: Linked insertion)

4. Which has extra memory per element for links?
   A. Array list
   B. Linked (dynamic) list
   C. Neither
   D. Both equally
   Answer: B. Each node holds a next pointer. (Key point: Memory overhead)

5. When are linked lists preferred?
   A. Fixed size and fast access
   B. Size varies with frequent insertions and deletions
   C. Memory is very tight
   D. Binary search needed
   Answer: B. They grow dynamically and avoid shifting. (Key point: When to choose)

## Related in Data Structure and Algorithm

- [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
- [Static vs dynamic list; getnode and freenode](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Astatic-dynamic-list-getnode-freenode) — Data Structure and Algorithm, chapter 3
- [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
- [Array list; static or dynamic choice](https://www.bctengineer.com/question.md?key=semester_4%2Fdata_structure_and_algorithm%3Aarray-list-static-dynamic-reason) — 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
- [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 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 and dynamic performance parameters](https://www.bctengineer.com/question.md?key=semester_4%2Finstrumentation_i%3Astatic-dynamic-performance-parameters) — Instrumentation I, chapter 2
- [Static versus dynamic balancing](https://www.bctengineer.com/question.md?key=semester_7%2Ftheory_of_mechanism_and_machine_ii%3Astatic-dynamic-balancing-differentiate) — Theory of Mechanism and Machine II, chapter 5
- [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×
