Foundations of Data Structures and Algorithms MCQs for the NSCT

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

Foundations of Data Structures and Algorithms is the groundwork of the DSA area: abstract data types (ADTs), what makes something an algorithm, asymptotic notation (Big-O, Omega and Theta) and recursion. It is the first of 12 topics in Data Structures & Algorithms, which carries 10% of the NSCT according to HEC's Areas of Competencies.

DSA was one of the weaker areas in 2026, with 40.2% average accuracy per the HEC NSCT report and APP. Everything later in the area, from sorting to hashing, is judged with the tools on this page.

ADTs

An abstract data type is a set of values plus the operations allowed on them, described by behaviour only. A data structure is a concrete way to store the data and code those operations.

ADT (what) Possible data structures (how)
Stack: push, pop, top Array, singly linked list
Queue: enqueue, dequeue Circular array, linked list with tail pointer
Priority queue: insert, remove-min Sorted array, binary heap
Map: put, get Hash table, balanced BST

One ADT can have several implementations with different costs. A priority queue on a sorted array inserts in O(n); on a binary heap it inserts in O(log n).

An algorithm is a finite sequence of well-defined steps that turns input into output. Knuth lists five properties: finiteness, definiteness, input, output and effectiveness. Being written in a particular language is not one of them.

Exam angle: if an option names behaviour only ("priority queue"), it is an ADT; if it names a layout ("binary heap in an array"), it is a data structure.

Asymptotic notation

Asymptotic notation describes how running time or memory grows as input size n grows, ignoring constants and small terms.

Notation Meaning Example
f = O(g) Upper bound: f(n) ≤ c·g(n) for large n 3n + 5 = O(n), and also O(n²)
f = Ω(g) Lower bound: f(n) ≥ c·g(n) for large n n² = Ω(n)
f = Θ(g) Tight bound: both O(g) and Ω(g) 3n² + 100n = Θ(n²)
f = o(g) Strictly slower, for every c > 0 n = o(n²)

The usual growth order is 1 < log n < √n < n < n log n < n² < 2ⁿ < n!.

To find the cost of code, count how many times the innermost statement runs:

for i in range(n):        # n times
    j = 1
    while j < n:          # about log2(n) times
        j *= 2

This is O(n log n). Nested loops multiply, loops in sequence add, and a counter that halves or doubles gives log n.

Keep best, worst and average case separate from O, Ω and Θ. Cases describe which input you analyse; the notations describe bounds. Insertion sort's worst case is Θ(n²) and its best case (sorted input) is Θ(n). Amortised cost averages over a whole sequence of operations, as with appending to a doubling dynamic array.

Exam angle: many questions ask for the tightest bound. O(n³) is a true but loose bound for 3n² + 7.

Recursion

Recursion is when a function solves a problem by calling itself on a smaller instance. Every recursive function needs a base case that stops the calls and a recursive case that moves towards it.

def fact(n):
    if n <= 1:          # base case
        return 1
    return n * fact(n - 1)

fact(5) returns 120. Each pending call keeps a frame on the call stack, so this uses O(n) extra space. A missing or unreachable base case fills the stack until it overflows; Python raises RecursionError.

A tail-recursive function makes its recursive call as its last action. Some compilers reuse the frame for this (tail-call optimisation), but CPython does not.

To cost a recursive algorithm, write a recurrence. T(n) = T(n - 1) + n unrolls to n(n + 1)/2 = Θ(n²). Naive Fibonacci, T(n) = T(n - 1) + T(n - 2) + 1, makes an exponential number of calls; memoisation cuts it to O(n).

Exam angle: for output questions, note whether the print happens before the recursive call (output on the way down) or after it (output on the way back, in reverse).

Common traps

Worked examples

1. Understanding. Which notation states only that an algorithm needs at least c·g(n) steps for large n? Answer: Big-Omega (Ω). It is a lower bound. Big-O is an upper bound and Θ is both.

2. Application. How many times does the body run in i = 1; while i <= 81: i *= 3? Answer: 5. i takes the values 1, 3, 9, 27 and 81 before reaching 243, so the loop is O(log₃ n).

3. Analysis. A function on input n does O(1) work and calls itself twice on n/2, stopping at n ≤ 1. A classmate says it is O(log n) because n halves each time. Is that right? Answer: no. The recurrence is T(n) = 2T(n/2) + 1. The depth is log n, but the number of calls doubles at each level: 1 + 2 + 4 + ... + n, about 2n calls (2,047 for n = 1,024). It is Θ(n).

Practise

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

Practise: 97 questions

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

  1. What does an abstract data type (ADT) specify?

    1. The exact memory layout of the data in RAM
    2. The operations on the data and how they behave, not how they are implemented
    3. A class written in one particular programming language
    4. A primitive type that the processor supports directly
    Show answer

    Answer: B. The operations on the data and how they behave, not how they are implemented

    An ADT is a logical description: a set of values plus the operations allowed on them and their behaviour (for example push, pop and top for a stack). How those operations are coded, with an array or a linked list, is a separate implementation decision.

  2. Which of the following is an abstract data type rather than a concrete data structure?

    1. Priority queue
    2. Binary heap stored in an array
    3. Singly linked list with a head pointer
    4. Fixed-size circular buffer
    Show answer

    Answer: A. Priority queue

    A priority queue is defined only by its operations: insert an item and remove the item with the highest priority. A binary heap, a linked list and a circular buffer are concrete structures that could be used to implement ADTs such as the priority queue or the queue.

  3. Which of these is NOT one of Knuth's required properties of an algorithm?

    1. Finiteness: it ends after a finite number of steps
    2. Definiteness: each step is precisely defined
    3. It must be written in a high-level programming language
    4. Effectiveness: each step is basic enough to be carried out
    Show answer

    Answer: C. It must be written in a high-level programming language

    Knuth lists five properties: finiteness, definiteness, input, output and effectiveness. An algorithm is independent of any language; it can be written in pseudocode, a flowchart or plain English.

  4. In asymptotic analysis, f(n) = O(g(n)) states that g(n) is:

    1. An asymptotic lower bound on f(n)
    2. An asymptotic upper bound on f(n)
    3. A tight bound, both upper and lower, on f(n)
    4. The exact number of steps f(n) takes
    Show answer

    Answer: B. An asymptotic upper bound on f(n)

    Big-O means there are constants c > 0 and n0 such that f(n) <= c*g(n) for all n >= n0. It bounds growth from above only. Big-Omega is the lower bound and Big-Theta is the tight bound.

  5. Which asymptotic notation gives a tight bound, meaning the function is bounded both above and below by constant multiples of g(n)?

    1. Big-O (O)
    2. Big-Omega (Ω)
    3. Big-Theta (Θ)
    4. Little-o (o)
    Show answer

    Answer: C. Big-Theta (Θ)

    f(n) = Θ(g(n)) holds when c1*g(n) <= f(n) <= c2*g(n) for all large n. That is the same as f being both O(g) and Ω(g). Little-o is a strict upper bound, so it is never tight.

  6. Which data structure does a running program use to keep track of active recursive calls?

    1. Queue
    2. Heap (priority queue)
    3. Call stack
    4. Hash table
    Show answer

    Answer: C. Call stack

    Each call pushes a stack frame holding its parameters, local variables and return address. The most recent call finishes first and its frame is popped, which is last-in, first-out behaviour.

  7. Which list is in strictly increasing order of growth rate?

    1. log n, √n, n log n, n², 2ⁿ
    2. √n, log n, n log n, n², 2ⁿ
    3. log n, √n, n², n log n, 2ⁿ
    4. log n, n log n, √n, n², 2ⁿ
    Show answer

    Answer: A. log n, √n, n log n, n², 2ⁿ

    Logarithms grow slower than any positive power of n, so log n < √n. Then n log n sits between n and n², and any exponential such as 2ⁿ outgrows every polynomial.

  8. What does worst-case running time tell you about an algorithm?

    1. The running time on a randomly chosen input of size n
    2. The largest running time over all inputs of size n, so no input of that size takes longer
    3. The running time on the input that the algorithm handles fastest
    4. The total time over a sequence of operations divided by their number
    Show answer

    Answer: B. The largest running time over all inputs of size n, so no input of that size takes longer

    Worst-case time is the maximum over all inputs of size n, which makes it a guarantee. A random-input expectation is average-case analysis, the fastest input is best case, and dividing a sequence's total cost by its length is amortised analysis.

  9. What normally happens when a recursive function has no reachable base case?

    1. The compiler converts it into a loop that ends after n steps
    2. It returns 0 after the first call
    3. It keeps calling itself until the call stack overflows
    4. It fails to compile because recursion requires a base case
    Show answer

    Answer: C. It keeps calling itself until the call stack overflows

    Without a base case nothing stops the calls, so each call adds a frame until stack memory runs out (a stack overflow; Python raises RecursionError). Compilers do not check for base cases.

  10. A recursive function is called tail-recursive when:

    1. The base case appears at the end of the function body
    2. It calls itself exactly twice
    3. The recursive call is the last action performed before the function returns
    4. It recurses on the last element of a list
    Show answer

    Answer: C. The recursive call is the last action performed before the function returns

    In tail recursion nothing is left to do after the recursive call returns, so the current frame is no longer needed. Some compilers reuse the frame (tail-call optimisation), turning the recursion into a loop.

FAQs

What is the difference between an ADT and a data structure?

An ADT says what operations are available and how they behave, for example a stack's push and pop. A data structure is a concrete storage layout that implements those operations, such as an array or a linked list. The same ADT can be built on different structures, each with different costs.

Is Big-O the same as worst-case time?

No, although they are often used together. Big-O is a type of bound (an upper bound), while worst case is a choice of input (the slowest one of size n). You can state a worst-case running time with Θ, and you can give an O bound for the best case. Textbooks such as CLRS keep the two ideas separate.

Is recursion slower than a loop?

Usually by a constant factor, because each call creates a stack frame, and recursion also uses O(depth) extra memory. The asymptotic time is often the same. Recursion becomes dramatically slower only when it repeats work, as naive Fibonacci does; memoisation or an iterative version removes that.

How do I find the time complexity of a loop quickly?

Ask how the loop counter changes. Adding a constant each step gives n iterations; multiplying or dividing by a constant gives log n. Then multiply for nested loops and add for loops in sequence, keeping only the fastest-growing term. When the inner loop depends on the outer counter, add up the actual counts.

Next step

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