Algorithms & Data Structures – MCQ Practice Test
Practise Algorithms & Data Structures with this free MCQ test for University Level students. Computer science notes on Big-O, arrays, stacks, queues, trees and sorting algorithms with examples. The questions follow the same ground as the study notes, so they are a good way to check what you have learned before an exam.
Below you will find 10 sample questions with answers and short explanations, at Intermediate and Advanced levels. Easy questions are worth 1 mark, Intermediate 2 marks and Advanced 3 marks. When you are ready, take the full timed test in the Test Zone — with a timer, negative marking and fresh questions every time.
Start the Algorithms & Data Structures test in the Test Zone → Pick “Algorithms & Data Structures” in the subject dropdown, then choose your level, number of questions and timer. Or read the notes for Algorithms & Data Structures first.
How this test works
In the full Test Zone test you choose how many questions to answer (10, 20, 30 or 50), a level — Easy, Intermediate, Advanced or Mixed — and an optional timer of 30, 45 or 60 seconds per question. Easy questions carry 1 mark, Intermediate 2 marks and Advanced 3 marks. You can switch on negative marking, which takes away a quarter of a question’s marks for a wrong answer; skipped questions score nothing. At the end you see your marks and percentage, a breakdown by level, and every question with the correct answer and a short explanation.
Sample questions: Algorithms & Data Structures
Try these 10 sample questions from the test. Choose an answer in your head, then tap “Show answer” to check yourself.
Q1. What is the time complexity of binary search on n sorted items? Intermediate · 2 marks
- O(1)
- O(n²)
- O(n)
- O(log n)
Show answer
Answer: D. O(log n). The search range halves each step, so about log₂ n steps are needed.
Q2. In which case does quick sort take O(n²) time? Advanced · 3 marks
- When the pivot is always the smallest or largest item
- When the list has an even length
- When all items are different
- When the data is random
Show answer
Answer: A. When the pivot is always the smallest or largest item. Unbalanced partitions make the recursion n levels deep.
Q3. Which algorithm finds shortest paths from one vertex in a graph with non-negative edge weights? Advanced · 3 marks
- Kruskal’s algorithm
- Prim’s algorithm
- Binary search
- Dijkstra’s algorithm
Show answer
Answer: D. Dijkstra’s algorithm. Dijkstra repeatedly picks the nearest unvisited vertex.
Q4. Which tree traversal visits the nodes of a binary search tree in sorted order? Intermediate · 2 marks
- Level-order
- Pre-order
- In-order
- Post-order
Show answer
Answer: C. In-order. In-order visits left, node, right, which gives ascending order in a BST.
Q5. What is the extra space complexity of merge sort? Advanced · 3 marks
- O(log n)
- O(1)
- O(n²)
- O(n)
Show answer
Answer: D. O(n). Merging needs a temporary array as large as the input.
Q6. Which data structure does breadth-first search (BFS) use? Intermediate · 2 marks
- Heap
- Stack
- Queue
- Hash table
Show answer
Answer: C. Queue. BFS explores level by level, so it uses a FIFO queue.
Q7. Which data structure is most often used to implement a priority queue? Advanced · 3 marks
- Hash table
- Singly linked list
- Binary heap
- Stack
Show answer
Answer: C. Binary heap. A heap gives O(log n) insert and remove-min.
Q8. Depth-first search (DFS) is naturally implemented with… Intermediate · 2 marks
- A sorted array
- A hash table
- A queue
- A stack (or recursion)
Show answer
Answer: D. A stack (or recursion). DFS goes deep first and backtracks, which is LIFO behaviour.
Q9. What is the time complexity of building a binary heap from n items (heapify)? Advanced · 3 marks
- O(log n)
- O(n²)
- O(n log n)
- O(n)
Show answer
Answer: D. O(n). Most nodes are near the bottom and sift down very little.
Q10. What is the average time complexity of merge sort? Intermediate · 2 marks
- O(n)
- O(log n)
- O(n log n)
- O(n²)
Show answer
Answer: C. O(n log n). Merge sort splits the list log n times and merges n items each level.
More practice tests
- Atomic Structure & the Periodic Table MCQ test
- World War I & II Comprehensive Study MCQ test
- Tawheed, Prophethood & Islamic Jurisprudence MCQ test
- Ideology of Pakistan & the 1973 Constitution MCQ test
Last updated: 23 November 2026. Back to the Test Zone · Algorithms & Data Structures notes & MCQs