HomeSubjectsUniversityBlogAbout

Foundations of DS & Algorithms

Topic in Data Structures & Algorithms

210 total MCQsShowing 30 with explanations10 Easy10 Medium10 Hard

About This Topic

A data structure organises data in memory for efficient access and change, while an algorithm is a finite sequence of steps that solves a problem. Foundational MCQs check that you can separate an abstract data type from its implementation, tell primitive types from composite ones, and read asymptotic notation correctly: Big-O as an upper bound, Omega as a lower bound and Theta as a tight bound. Common tasks include simplifying expressions like 3n^2 + 5n + 7 to O(n^2), ranking growth rates such as O(2^n) against O(n^3), counting nested-loop iterations, and analysing recursion with tail calls, recursion trees and simple recurrences.

Below are 30 practice questions from a pool of 210 Foundations of DS & Algorithms MCQs, one of 12 topics in Data Structures & Algorithms. Each shows the correct answer with an explanation; when you are ready, take a timed quiz to test recall under exam conditions.

Practice Questions

Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.

Foundations of DS & AlgorithmsEasy

Q1. What is a data structure?

  1. A.A specific programming language type
  2. B.A step-by-step problem procedure
  3. C.A physical hardware component unit
  4. D.A way to organize and store data✓ Correct

Explanation

A data structure is a way to organize, manage, and store data so that it can be accessed and modified efficiently.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q2. What does 'algorithm' mean?

  1. A.A compiled programming language
  2. B.A primitive data type definition
  3. C.A processing hardware component
  4. D.A step-by-step problem procedure✓ Correct

Explanation

An algorithm is a finite set of well-defined instructions or steps to solve a specific problem or perform a computation.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q3. Which notation is used to describe the upper bound of an algorithm's time complexity?

  1. A.Small-o notation
  2. B.Theta notation
  3. C.Omega notation
  4. D.Big-O notation✓ Correct

Explanation

Big-O notation describes the upper bound (worst case) of an algorithm's growth rate.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q4. What is the time complexity of accessing an element in an array by index?

  1. A.O(n)
  2. B.O(log n)
  3. C.O(1)✓ Correct
  4. D.O(n^2)

Explanation

Array elements can be accessed directly using their index in constant time O(1).

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q5. Which of the following is a linear data structure?

  1. A.Graph
  2. B.Array✓ Correct
  3. C.Heap
  4. D.Tree

Explanation

An array is a linear data structure where elements are stored in contiguous memory locations.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q6. What is the purpose of pseudocode?

  1. A.To execute low-level machine instructions
  2. B.To debug and test running software
  3. C.To compile a program into bytecode
  4. D.To describe an algorithm in readable form✓ Correct

Explanation

Pseudocode is used to represent an algorithm in a structured, human-readable format without worrying about syntax of a specific language.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q7. Which term refers to the amount of memory an algorithm uses?

  1. A.Time complexity
  2. B.Code complexity
  3. C.Space complexity✓ Correct
  4. D.Cyclomatic complexity

Explanation

Space complexity measures the total amount of memory space required by an algorithm as a function of input size.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q8. What is O(1) complexity called?

  1. A.Constant✓ Correct
  2. B.Quadratic
  3. C.Logarithmic
  4. D.Linear

Explanation

O(1) is called constant time complexity because the execution time does not change with input size.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q9. Which of the following is a non-linear data structure?

  1. A.Linked List
  2. B.Stack
  3. C.Array
  4. D.Tree✓ Correct

Explanation

A tree is a non-linear data structure where elements are arranged in a hierarchical manner.

Report an error in this question

Foundations of DS & AlgorithmsEasy

Q10. What is an Abstract Data Type (ADT)?

  1. A.A concrete implementation of a data structure
  2. B.A reserved programming language keyword term
  3. C.A specific type of comparison sorting algorithm
  4. D.A mathematical model defined by its behavior✓ Correct

Explanation

An ADT is a mathematical model that defines a data type by its behavior (operations) rather than its implementation.

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q11. What is the time complexity of the recurrence T(n) = 2T(n/2) + n?

  1. A.O(n^2)
  2. B.O(log n)
  3. C.O(n)
  4. D.O(n log n)✓ Correct

Explanation

By the Master Theorem (case 2), T(n) = 2T(n/2) + n gives O(n log n).

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q12. Which case of the Master Theorem applies when f(n) = Θ(n^(log_b(a)))?

  1. A.Case 3 applies
  2. B.No case applies
  3. C.Case 2 applies✓ Correct
  4. D.Case 1 applies

Explanation

Case 2 of the Master Theorem applies when f(n) = Θ(n^(log_b(a))), giving T(n) = Θ(n^(log_b(a)) * log n).

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q13. What does Omega (Ω) notation represent?

  1. A.Exact tight bound complexity
  2. B.Worst-case upper bound complexity
  3. C.Best-case or lower bound complexity✓ Correct
  4. D.Average-case expected complexity

Explanation

Omega notation provides an asymptotic lower bound on the growth rate of an algorithm.

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q14. If an algorithm has complexities O(n^2) in the worst case and Ω(n) in the best case, which is true?

  1. A.The algorithm always runs in O(n) time
  2. B.The algorithm always runs in O(n^2) time
  3. C.The algorithm runs in O(n log n) always
  4. D.Performance varies between Ω(n) and O(n^2)✓ Correct

Explanation

The algorithm's performance ranges from the lower bound Ω(n) in the best case to the upper bound O(n^2) in the worst case.

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q15. What is amortized analysis?

  1. A.Analyzing the worst case of each operation individually
  2. B.Averaging the cost of operations over a sequence✓ Correct
  3. C.Analyzing only the best case of each operation
  4. D.Computing the cost using a sorting-based analysis

Explanation

Amortized analysis averages the time required to perform a sequence of operations, giving a tighter bound than worst-case per operation.

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q16. Which growth rate is faster: O(2^n) or O(n^3)?

  1. A.They are the same
  2. B.O(n^3) is faster
  3. C.O(2^n) is faster✓ Correct
  4. D.Depends on input size

Explanation

Exponential growth O(2^n) grows much faster than polynomial growth O(n^3) for large n.

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q17. What is the time complexity of a nested loop where both loops run n times?

  1. A.O(n log n)
  2. B.O(n^2)✓ Correct
  3. C.O(2n)
  4. D.O(n)

Explanation

Two nested loops each running n times result in n × n = n^2 iterations, giving O(n^2).

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q18. In asymptotic analysis, which of these is the correct ordering from slowest to fastest growth?

  1. A.O(1) < O(log n) < O(n) < O(n^2)✓ Correct
  2. B.O(1) < O(n) < O(log n) < O(n^2)
  3. C.O(n) < O(log n) < O(1) < O(n^2)
  4. D.O(log n) < O(1) < O(n) < O(n^2)

Explanation

The correct growth order is: O(1) < O(log n) < O(n) < O(n^2).

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q19. What is the recurrence relation for binary search?

  1. A.T(n) = 2T(n/2) + 1
  2. B.T(n) = T(n-1) + 1
  3. C.T(n) = T(n/2) + n
  4. D.T(n) = T(n/2) + 1✓ Correct

Explanation

Binary search divides the problem in half each time and does constant work, giving T(n) = T(n/2) + 1.

Report an error in this question

Foundations of DS & AlgorithmsMedium

Q20. What does Theta (Θ) notation represent?

  1. A.Only upper bound estimate
  2. B.Tight bound (both upper and lower)✓ Correct
  3. C.Only lower bound estimate
  4. D.Average case analysis only

Explanation

Theta notation provides a tight bound, meaning the function grows at the same rate asymptotically (both upper and lower bounds match).

Report an error in this question

Foundations of DS & AlgorithmsHard

Q21. What is the time complexity of the recurrence T(n) = 3T(n/4) + n log n?

  1. A.O(n^(log_4(3)))
  2. B.O(n^2)
  3. C.O(n log^2 n)
  4. D.O(n log n)✓ Correct

Explanation

Using Master Theorem case 3: log_4(3) ≈ 0.79 < 1, and f(n) = n log n = Ω(n^(0.79+ε)), so T(n) = Θ(n log n).

Report an error in this question

Foundations of DS & AlgorithmsHard

Q22. Which of the following recurrences cannot be solved by the Master Theorem?

  1. A.T(n) = T(n-1) + n✓ Correct
  2. B.T(n) = 2T(n/2) + n log n
  3. C.T(n) = 2T(n/2) + n
  4. D.T(n) = 4T(n/2) + n^2

Explanation

T(n) = T(n-1) + n is not in the form T(n) = aT(n/b) + f(n) required by the Master Theorem, as it subtracts rather than divides.

Report an error in this question

Foundations of DS & AlgorithmsHard

Q23. What is the amortized cost of insertion in a dynamic array that doubles its size when full?

  1. A.O(1)✓ Correct
  2. B.O(n^2)
  3. C.O(log n)
  4. D.O(n)

Explanation

Although occasional resizing costs O(n), the amortized cost over n insertions is O(1) per insertion using aggregate analysis.

Report an error in this question

Foundations of DS & AlgorithmsHard

Q24. Using the substitution method, what is the solution to T(n) = T(n-1) + n with T(1) = 1?

  1. A.O(2^n)
  2. B.O(n log n)
  3. C.O(n)
  4. D.O(n^2)✓ Correct

Explanation

Expanding: T(n) = n + (n-1) + ... + 1 = n(n+1)/2 = O(n^2).

Report an error in this question

Foundations of DS & AlgorithmsHard

Q25. What is the lower bound for any comparison-based sorting algorithm?

  1. A.O(n log n)✓ Correct
  2. B.O(n^2)
  3. C.O(log n)
  4. D.O(n)

Explanation

Any comparison-based sorting algorithm requires at least Ω(n log n) comparisons in the worst case, proven via decision tree analysis.

Report an error in this question

Foundations of DS & AlgorithmsHard

Q26. In the potential method of amortized analysis, the amortized cost is defined as:

  1. A.Actual cost × potential function
  2. B.Actual cost + change in potential✓ Correct
  3. C.Actual cost - change in potential
  4. D.Actual cost / potential function

Explanation

In the potential method, amortized cost = actual cost + (Φ(after) - Φ(before)), where Φ is the potential function.

Report an error in this question

Foundations of DS & AlgorithmsHard

Q27. What complexity class does the problem of finding the median of an unsorted array belong to?

  1. A.O(n^2) minimum brute force
  2. B.O(n log n) using sort first
  3. C.O(n) using deterministic selection✓ Correct
  4. D.O(log n) using binary search

Explanation

The median can be found in O(n) worst-case time using the median-of-medians deterministic selection algorithm.

Report an error in this question

Foundations of DS & AlgorithmsHard

Q28. What is the space complexity of a recursive algorithm with depth d and O(1) space per call?

  1. A.O(d)✓ Correct
  2. B.O(2^d)
  3. C.O(d^2)
  4. D.O(1)

Explanation

Each recursive call adds a frame to the call stack. With depth d and O(1) per frame, total space is O(d).

Report an error in this question

Foundations of DS & AlgorithmsHard

Q29. Which of the following is true about the relationship between time and space complexity?

  1. A.Space complexity can exceed time complexity
  2. B.Space complexity cannot exceed time complexity✓ Correct
  3. C.Time complexity is always greater than space
  4. D.Time and space complexity are always equal

Explanation

An algorithm cannot use more space than time, because writing to each memory cell takes at least one time step. So space ≤ time.

Report an error in this question

Foundations of DS & AlgorithmsHard

Q30. What is the time complexity of T(n) = 2T(n/2) + n/log n?

  1. A.O(n)
  2. B.O(n log n)
  3. C.O(n log log n)✓ Correct
  4. D.O(n (log n)^2)

Explanation

This recurrence falls in a gap of the Master Theorem. Using the Akra-Bazzi method or recursion tree, T(n) = O(n log log n).

Report an error in this question

Ready to test yourself on Foundations of DS & Algorithms?

Take a timed quiz drawn from 210+ questions on this topic. No signup required — your progress saves in your browser.

Start Foundations of DS & Algorithms Quiz