Sample Quizzes For Preparation: Algorithms
A2 Level Computer Science – Quiz
Topic: 19.1 Algorithms (Computational Thinking and Problem-Solving)
Question 1
Which of the following is true about binary search?
A. It can be used on unsorted data
B. It always has a time complexity of O(n)
C. It reduces the search space by half each time
D. It performs better than linear search only on very small datasets
Question 2
What is the time complexity of bubble sort in the worst-case scenario?
A. O(n)
B. O(log n)
C. O(n log n)
D. O(n²)
Question 3
In insertion sort, what happens when the array is already sorted?
A. Worst-case time complexity applies
B. Best-case time complexity applies
C. No comparisons are made
D. Time complexity becomes O(n²)
Question 4
Which data structure uses the LIFO (Last In First Out) principle?
A. Queue
B. Stack
C. Linked List
D. Binary Tree
Question 5
What is required for binary search to function correctly?
A. The data must be numeric
B. The data must be in descending order
C. The data must be sorted
D. The data must be in reverse order
Question 6
Which sorting algorithm compares adjacent elements and swaps them if they are in the wrong order?
A. Merge Sort
B. Insertion Sort
C. Bubble Sort
D. Selection Sort
Question 7
Which of the following is not a characteristic of an Abstract Data Type (ADT)?
A. Defines operations
B. Defines implementation
C. Hides data representation
D. Can be implemented using other ADTs
Question 8
In a queue, which operation removes the front element?
A. Pop
B. Enqueue
C. Dequeue
D. Push
Question 9
Which ADT is most suitable for implementing recursive function call stacks?
A. Queue
B. Linked List
C. Dictionary
D. Stack
Question 10
How many comparisons are required in the worst case when performing binary search on a 1024-element sorted array?
A. 10
B. 1024
C. 512
D. 2
Question 11
Which of the following best describes Big O notation?
A. Describes the fastest possible runtime
B. Describes the number of elements in an array
C. Describes the upper bound of algorithm performance
D. Describes only best-case scenarios
Question 12
Which sorting method performs best when the input is nearly sorted?
A. Quick Sort
B. Merge Sort
C. Insertion Sort
D. Bubble Sort
Question 13
What is the worst-case time complexity for inserting into a linked list at the end?
A. O(1)
B. O(log n)
C. O(n)
D. O(n²)
Question 14
Which data structure is commonly used to implement a breadth-first search (BFS)?
A. Stack
B. Queue
C. Tree
D. Dictionary
Question 15
In a binary search tree, where is the smallest value found?
A. Right-most node
B. Root node
C. Left-most node
D. Middle node
Question 16
Which is a correct statement about a graph?
A. It cannot have cycles
B. It must be a tree
C. It consists of nodes and edges
D. It only supports undirected connections
Question 17
What does the n + 1 rule in pseudocode refer to?
A. Number of steps in a loop
B. Stack size
C. Split pattern in NMR
D. Not relevant to algorithms
Question 18
Which algorithm has a constant time complexity for insertion at the head of a linked list?
A. Bubble Sort
B. Insertion Sort
C. Linked List insertion at tail
D. Linked List insertion at head
Question 19
Which of the following cannot be used to define an ADT?
A. Pseudocode
B. Flowchart
C. Implementation code
D. Interface definition
Question 20
What is the average-case time complexity of a linear search?
A. O(1)
B. O(n/2)
C. O(n)
D. O(log n)
Question 21
Which of the following best represents a dictionary ADT?
A. FIFO
B. Key-value pair storage
C. Indexed access
D. Sequential traversal
Question 22
Which of the following is a composite ADT?
A. Integer
B. String
C. Stack
D. Record
Question 23
What is the time complexity of deleting the front element from a queue?
A. O(n²)
B. O(log n)
C. O(1)
D. O(n)
Question 24
Which factor does not affect time complexity?
A. Data order
B. Number of loops
C. Size of input
D. Colour of code editor
Question 25
Which is NOT a key characteristic of Big O analysis?
A. Memory usage
B. Hardware speed
C. Time growth rate
D. Input size dependency
Question 26
In stepwise refinement, what is the purpose of each step?
A. To write efficient code
B. To reduce time complexity
C. To break down the problem into smaller parts
D. To increase recursion
Question 27
Which of these ADTs is best suited for undo operations?
A. Queue
B. Dictionary
C. Stack
D. Linked List
Question 28
Why is binary search not suitable for a linked list?
A. Takes more memory
B. Cannot divide the list efficiently
C. Linked lists are unsorted
D. No random access
Question 29
Which ADT is best for managing customer service ticket queues?
A. Stack
B. Queue
C. Linked List
D. Graph
Question 30
Which sorting algorithm works well for small lists and nearly sorted data?
A. Merge Sort
B. Heap Sort
C. Insertion Sort
D. Selection Sort
Marking Key and Detailed Explanations – A2 Computer Science | Topic 19.1 Algorithms
Q1. C
Binary search works by halving the search space each time.
A is wrong – binary search only works on sorted data.
B is wrong – its time complexity is O(log n), not O(n).
D is wrong – binary search outperforms linear search on large datasets.
Q2. D
Bubble sort has a worst-case time complexity of O(n²) due to nested loops for comparisons and swaps.
A is the best case (when already sorted).
C is for merge sort.
Q3. B
Best-case for insertion sort occurs when the array is already sorted, resulting in O(n).
A and D describe worst case.
C is false – comparisons still happen.
Q4. B
A stack follows LIFO – Last In First Out.
A (Queue) – FIFO
C (Linked List) – can be either
D (Binary Tree) – hierarchical structure
Q5. C
Sorted data is essential for binary search to function.
A, B, D – incorrect conditions.
Q6. C
Bubble sort repeatedly compares adjacent pairs and swaps if needed.
A, B, D use different sorting mechanisms.
Q7. B
ADT defines operations and hides implementation.
B is incorrect – implementation details are hidden, not defined.
Q8. C
Dequeue removes the front element in a queue.
A and D are stack operations.
Q9. D
Stacks manage recursive calls, due to LIFO order.
Other options – not applicable for recursion management.
Q10. A
1024 = 2¹⁰ ⇒ log₂(1024) = 10 comparisons max.
B, C, D are miscalculations.
Q11. C
Big O describes upper bound of algorithm’s growth.
A, D are incorrect.
B – irrelevant.
Q12. C
Insertion sort is efficient on nearly sorted data due to fewer shifts.
A, B, D are general-purpose sorts.
Q13. C
To insert at the end, you must traverse the list ⇒ O(n).
A applies for inserting at the head.
Q14. B
Queue is used for BFS traversal (FIFO).
A (Stack) is used in DFS.
Q15. C
In BST, smallest value is always the left-most node.
Others are incorrect based on BST logic.
Q16. C
Graphs are collections of nodes and edges.
A, B, D are false – graphs can have cycles and can be directed/undirected.
Q17. D
The n + 1 rule applies to NMR spectroscopy, not algorithms.
Not relevant here.
Q18. D
Inserting at head is O(1) in a singly linked list.
C (tail insertion) is O(n) unless tail pointer is maintained.
Q19. C
Implementation code is not needed to define an ADT – just interface/behavior.
A, B, D help define ADTs.
Q20. C
Average case for linear search = O(n).
B (O(n/2)) simplifies to O(n) in Big O.
Q21. B
Dictionary stores data in key-value pairs.
A, C, D are different access models.
Q22. D
Records are composite types made of fields.
A, B are primitives.
C (Stack) is ADT but not composite in the data definition sense.
Q23. C
Dequeuing from the front is O(1) for queues.
D applies for arrays but not linked list-based queues.
Q24. D
Editor color does not affect algorithm performance.
A, B, C are valid complexity factors.
Q25. B
Big O focuses on logic and input size, not hardware speed.
A, C, D are part of Big O analysis.
Q26. C
Stepwise refinement decomposes tasks into manageable steps for clarity and implementation.
Others are not main goals.
Q27. C
Stack is ideal for undo – last action is reversed first (LIFO).
A (Queue) is FIFO – unsuitable.
Q28. D
Binary search requires random access (like arrays), which linked lists don’t support efficiently.
Q29. B
Queue manages first-come, first-serve logic used in ticket systems.
Others are structurally unsuitable.
Q30. C
Insertion sort is simple and works well for small/nearly sorted data.
A, B, D are more complex and less efficient in that context.