Linear Data Structures MCQs for the NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

Linear data structures store elements in a sequence, where each element has at most one predecessor and one successor: arrays, linked lists, stacks and queues. They are the second of 12 topics in the Data Structures & Algorithms area, which carries 10% of the NSCT according to HEC's Areas of Competencies.

Expect cost questions (what is O(1) and what is O(n)?) and hand traces of push, pop, enqueue and dequeue. The Big-O tools come from Foundations of DSA.

Arrays

An array stores elements of the same size in one contiguous block, so the address of A[i] is base + i × size. That gives O(1) access by index, but inserting or deleting in the middle shifts elements, which is O(n).

For a 2D array the layout matters. Take int A[5][8] at base 1000 with 4-byte ints and 0-based indices:

Order Formula for A[i][j] A[3][5]
Row-major (C, C++) base + (i × cols + j) × size 1000 + 29 × 4 = 1116
Column-major (Fortran, MATLAB) base + (j × rows + i) × size 1000 + 28 × 4 = 1112

A dynamic array (Python list, C++ vector, Java ArrayList) grows by a constant factor, usually doubling, so appending is amortised O(1).

Exam angle: check whether a question uses 0-based or 1-based indices before applying the formula; with 1-based indices you subtract 1 first.

Linked lists

A linked list is a chain of nodes, each holding data and a pointer to the next node. There is no random access, but inserting at a known position only changes pointers.

Operation Array Singly linked list (head only)
Access i-th element O(1) O(n)
Insert at front O(n) O(1)
Insert at end O(1) amortised O(n), or O(1) with a tail pointer
Delete a given node O(n) O(n) to find its predecessor

A doubly linked list adds a previous pointer, so deleting a node you already hold is O(1), at the cost of one extra pointer per node. In a circular list the last node points back to the head.

Exam angle: reversing a singly linked list in place needs three pointers (previous, current, next) and is O(n) time, O(1) space.

Stacks

A stack is a last-in, first-out (LIFO) ADT with push, pop and peek, all O(1). Popping an empty stack is underflow; pushing onto a full fixed-size stack is overflow.

push 5, push 8, pop, push 3  ->  [5, 3]   (top = 3)

Classic uses: function calls, undo, balanced brackets, and converting and evaluating expressions. To evaluate postfix, push operands; on an operator, pop the right operand first, then the left. A linked-list stack pushes and pops at the head, because popping at the tail needs the predecessor.

Exam angle: if 1, 2, 3, 4 are pushed in order, a pop sequence that starts with 4 must continue 3, 2, 1. Sequences that break this, such as 4 2 3 1, are impossible. See stack and queue applications for full infix-to-postfix traces.

Queues

A queue is a first-in, first-out (FIFO) ADT: enqueue at the rear, dequeue at the front. Variants you need:

Variant Key idea
Circular queue Indices wrap with % n, so freed slots are reused
Deque Insert and delete at both ends
Priority queue Removes the highest-priority item, usually with a heap

In a circular queue that keeps one slot empty, the queue is empty when front == rear and full when (rear + 1) % n == front. It therefore holds at most n - 1 items.

Exam angle: in Python, list.pop(0) shifts every element, so a list-based queue is O(n) per dequeue. collections.deque.popleft() is O(1).

Common traps

Worked examples

1. Understanding. Which linear structure does breadth-first search use to hold the vertices waiting to be visited? Answer: a queue. BFS must visit vertices in the order it discovers them, which is FIFO.

2. Application. Evaluate the postfix expression 5 1 2 + 4 * + 3 -. Answer: 14. 1 2 + gives 3; 3 4 * gives 12; 5 12 + gives 17; 17 3 - gives 14.

3. Analysis. A queue is built on a singly linked list with head and tail pointers. Why enqueue at the tail and dequeue at the head, not the other way round? Answer: removing at the tail needs the node before the tail, an O(n) walk. Adding at the tail and removing at the head are both O(1).

Practise

The quiz below has 100 questions on this topic, filterable by tier and difficulty.

Practise: 100 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. Which access order does a stack follow?

    1. First in, first out (FIFO)
    2. Last in, first out (LIFO)
    3. Highest priority out first
    4. Random access by index
    Show answer

    Answer: B. Last in, first out (LIFO)

    A stack only allows insertion (push) and removal (pop) at one end, the top, so the most recently pushed item is the first to leave. FIFO describes a queue, and highest-priority-first describes a priority queue.

  2. In a standard queue, where are elements inserted and removed?

    1. Inserted and removed at the front
    2. Inserted at the front and removed from the rear
    3. Inserted at the rear and removed from the front
    4. Inserted and removed at the rear
    Show answer

    Answer: C. Inserted at the rear and removed from the front

    A queue is first in, first out: enqueue adds at the rear and dequeue removes from the front, so items leave in arrival order. Using the same end for both would make it a stack.

  3. Why can an array element be read by index in O(1) time?

    1. The array is searched from the start until the index is found
    2. Its address is computed directly as base address + index × element size
    3. Each element stores a pointer to the next one
    4. Arrays are always kept sorted
    Show answer

    Answer: B. Its address is computed directly as base address + index × element size

    Array elements sit in one contiguous block of equal-sized slots, so the address of A[i] is base + i × size, a single calculation. Following pointers is how a linked list works, and that takes O(n) to reach position i.

  4. What does a node of a singly linked list contain?

    1. A data field and pointers to the previous and next nodes
    2. Only a data field; nodes are found by index
    3. A data field and a pointer to the next node
    4. A data field and pointers to left and right children
    Show answer

    Answer: C. A data field and a pointer to the next node

    A singly linked list node holds the value plus one link to its successor; the last node's link is null. Previous and next pointers make a doubly linked list, and left and right children make a binary tree node.

  5. What does the peek (or top) operation on a stack do?

    1. Removes and returns the top element
    2. Returns the bottom element
    3. Returns the top element without removing it
    4. Returns the number of elements in the stack
    Show answer

    Answer: C. Returns the top element without removing it

    peek lets you inspect the top item while leaving the stack unchanged. pop both returns and removes it, and size returns the count.

  6. For a singly linked list with only a head pointer (no tail pointer), what are the costs of inserting at the head and at the end?

    1. Head O(n), end O(1)
    2. Both O(1)
    3. Both O(n)
    4. Head O(1), end O(n)
    Show answer

    Answer: D. Head O(1), end O(n)

    Inserting at the head means creating a node, pointing it at the old head and updating head: constant time. Reaching the last node needs a walk through all n nodes. Keeping a tail pointer makes end insertion O(1) too.

  7. You have a pointer to a node X in a doubly linked list. Why can X be deleted in O(1), when a singly linked list needs O(n) for the same job?

    1. X stores a pointer to its predecessor, so the previous node can be relinked directly
    2. Doubly linked lists are stored contiguously like arrays
    3. Doubly linked lists are always sorted
    4. Deletion in a doubly linked list does not change any pointers
    Show answer

    Answer: A. X stores a pointer to its predecessor, so the previous node can be relinked directly

    To unlink X, the node before it must point past it. In a doubly linked list X.prev gives that node immediately; in a singly linked list you must walk from the head to find it, which is O(n).

  8. Which problem of a simple array-based linear queue does a circular queue solve?

    1. Elements cannot be accessed by index
    2. Dequeue takes O(n) time because of pointer chasing
    3. Slots freed at the front cannot be reused once the rear reaches the end of the array
    4. The queue cannot hold duplicate values
    Show answer

    Answer: C. Slots freed at the front cannot be reused once the rear reaches the end of the array

    In a linear queue, front and rear only move forward, so after some dequeues the queue can report 'full' while the front of the array is empty. A circular queue wraps the indices with modulo arithmetic so those slots are reused.

  9. Calling pop on an empty stack causes which condition?

    1. Stack overflow
    2. Memory leak
    3. Segmentation into two stacks
    4. Stack underflow
    Show answer

    Answer: D. Stack underflow

    Underflow means removing from an empty structure. Overflow is the opposite: pushing onto a stack that is already full, such as a fixed-size array stack.

  10. Which structure allows insertion and deletion at both ends?

    1. Deque (double-ended queue)
    2. Stack
    3. Priority queue
    4. Singly linked list without a tail pointer
    Show answer

    Answer: A. Deque (double-ended queue)

    A deque supports add and remove at both the front and the rear, so it can act as both a stack and a queue. Python's collections.deque does each of these in O(1).

FAQs

What is the difference between linear and non-linear data structures?

In a linear structure, elements form a single sequence: each has at most one predecessor and one successor, as in arrays, lists, stacks and queues. In a non-linear structure, an element can connect to several others, as in trees and graphs. Our non-linear data structures page covers those.

When should I use a linked list instead of an array?

Use a linked list when you insert and delete often at known positions, such as the front, and rarely need the i-th element. Use an array when you need fast access by index, good cache performance or compact memory. In practice dynamic arrays win most of the time.

Is a stack an ADT or a data structure?

A stack is an ADT, because it is defined by its operations (push, pop, peek) and LIFO behaviour. An array-based stack and a linked-list stack are two data structures that implement it. Exam options often use "stack" loosely for both.

Why does a circular queue leave one slot empty?

With front == rear meaning empty, a completely full array would also give front == rear, so the two states would look the same. Keeping one slot free makes full mean (rear + 1) % n == front. The other common fix is to keep a separate count of elements.

Next step

Move on to Non-Linear Data Structures MCQs, see all topics on the DSA MCQs hub, or test yourself in an NSCT mock test.