PadhaikoAll subjects

Past exam question: 2066 Bhadra (Regular / Back), Q3(b)

Data Structure and Algorithms · 2 marks

Open in the Padhaiko app

Topic: Linked List

Question

Explain the advantages of dynamic implementation of stack and queue over sequential storage to represent stack and queue.

Solution

Advantages of Dynamic (Linked) Stack & Queue over Sequential (Array) Storage:

  1. No Fixed Capacity / No False Overflow: Size grows and shrinks dynamically at runtime via malloc/free, avoiding compile-time MAX limits and linear-queue false overflow.
  2. Zero Unused Memory Wastage: Memory is allocated strictly for currently stored items rather than reserving a worst-case fixed array.
  3. Flexible Non-Contiguous Storage: Nodes can reside in scattered heap locations instead of requiring one large contiguous block.
Answer:

Dynamic linked implementations of stacks and queues eliminate fixed MAX overflow, avoid pre-allocating unused array space, and use scattered heap memory instead of large contiguous blocks.

All past exam questions for Data Structure and Algorithms