wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Algorithm Design and Analysis Quiz

Total questions: 45

Worksheet time: 23mins

Name
Class
Date
1.

Scenario: You are asked to create a sorting algorithm for a system that handles millions of transactions per second. Which design paradigm is most appropriate for such scenarios?

a)

Divide and Conquer

b)

Brute Force

c)

Randomized Algorithms

d)

Greedy Algorithms

2.

Scenario: A company needs an algorithm to verify user credentials against a database with billions of entries. Which factor is most critical to evaluate the algorithm?

a)

Accuracy

b)

Space complexity

c)

Time complexity

d)

Input constraints

3.

Scenario: An algorithm consistently outputs the wrong results for certain inputs. What property of the algorithm is being violated?

a)

Efficiency

b)

Correctness

c)

Simplicity

d)

Stability

4.

Scenario: Your algorithm processes T(n)=4T(n/2)+n2. Using Master’s Theorem, identify the time complexity.

a)

O(n2logn)

b)

O(n3)

c)

O(n2)

d)

O(logn)

5.

Scenario: A function f(n)=5n3+3n2. As nn grows large, what is the asymptotic upper bound?

a)

O(n2)

b)

O(n3)

c)

O(5n3)

d)

O(n4)

6.

Scenario: An algorithm's time complexity is O(log n). What scenario best fits its application?

a)

Searching for an element in a sorted array

b)

Sorting an array

c)

Finding the shortest path in a graph

d)

Traversing a linked list

7.

Scenario: A recursive algorithm divides a problem into 3 subproblems, each half the size of the original. The recurrence is T(n)=3T(n/2)+n. What is the time complexity?

a)

O(n2)

b)

O(nlogn)

c)

O(nlog23)

d)

O(n)

8.

Scenario: For the recurrence T(n)=2T(n/4)+√n, , what is the asymptotic complexity?

a)

O(logn)

b)

O(n1/2)

c)

O(n0.5 logn)

d)

O(nlogn)

9.

Scenario: A binary tree is used to represent a decision-making process. Which traversal gives the sequence of decisions in increasing order of priority?

a)

Preorder

b)

Postorder

c)

Inorder

d)

Level order

10.

Scenario: You implement a queue in a ticket booking system where the first customer to arrive gets served first. Which principle does the queue follow?

a)

FIFO

b)

LIFO

c)

Priority-based

d)

Random access

11.

Scenario: In a text editor, the undo operation is implemented using which data structure?

a)

Queue

b)

Stack

c)

Binary tree

d)

Graph

12.

Scenario: A balanced binary search tree (BST) is used for searching. What is the worst-case time complexity?

a)

O(1)

b)

O(n)

c)

O(logn)

d)

O(nlogn)

13.

Scenario: Your task is to design a network of roads with minimal total cost. Which algorithm would work best for the problem?

a)

Dijkstra’s Algorithm

b)

Kruskal’s Algorithm

c)

Floyd-Warshall Algorithm

d)

Bellman-Ford Algorithm

14.

Scenario: Prim’s algorithm starts from:

a)

The vertex with the minimum degree

b)

Any vertex

c)

The vertex with the maximum degree

d)

The vertex with the smallest edge weight

15.

Scenario: In a graph with negative edge weights, which algorithm would you use to find the Minimum Spanning Tree?

a)

Kruskal’s Algorithm

b)

Prim’s Algorithm

c)

Both

d)

None

16.

Scenario: You are solving a problem where the solution depends on overlapping subproblems. Which approach would you use?

a)

Divide and Conquer

b)

Brute Force

c)

Dynamic Programming

d)

Greedy Algorithms

17.

Scenario: The traveling salesman problem is solved using dynamic programming. What is its time complexity?

a)

O(n2)

b)

O(n22n)

c)

O(2n)

d)

O(n!)

18.

Scenario: You are solving the Longest Common Subsequence problem. Which method will provide the optimal solution?

a)

Backtracking

b)

Greedy Algorithms

c)

Dynamic Programming

d)

Divide and Conquer

19.

Scenario: You need to fill a knapsack to maximize profit, where items can be broken into smaller parts. Which algorithm will give the optimal solution?

a)

Dynamic Programming

b)

Brute Force

c)

Greedy Algorithm

d)

Divide and Conquer

20.

Scenario: In a cash-dispenser system, the machine is programmed to return the fewest coins possible. Which principle is this based on?

a)

Backtracking

b)

Greedy Algorithm

c)

Dynamic Programming

d)

Linear Programming

21.

Scenario: Your database contains sorted records, and you need to find an element quickly. Which search algorithm would you use?

a)

Linear Search

b)

Binary Search

c)

Breadth-First Search

d)

Depth-First Search

22.

Scenario: A hash table is used for fast lookups. What is the average-case time complexity for a successful search?

a)

O(n)

b)

O(1)

c)

O(logn)

d)

O(nlogn)

23.

Scenario: A company wants to implement a scheduling system where tasks need to be prioritized and executed quickly. Which algorithmic design technique is most appropriate?

a)

Divide and Conquer

b)

Greedy Algorithm

c)

Dynamic Programming

d)

Backtracking

24.

Scenario: You have been given a problem where there is no efficient solution, and the exact solution is required only for small instances. What approach is most suitable?

a)

Brute Force

b)

Approximation Algorithms

c)

Randomized Algorithms

d)

Divide and Conquer

25.

Scenario: A sorting algorithm has a time complexity of O(n2). Which input size is feasible for this algorithm to run within a few seconds?

a)

n=104

b)

n=102

c)

n=106

d)

n=103

26.

Scenario: Given an algorithm with a time complexity of O(2n), for what input size does it become impractical?

a)

n=10

b)

n=20

c)

n=50

d)

n=100

27.

Scenario: Which of the following is an example of Ω(n) performance in the best case?

a)

Searching for an element in a sorted array using linear search

b)

Sorting an array using quicksort

c)

Searching for an element using binary search

d)

Traversing a graph with DFS

28.

Scenario: A recursive function solves T(n)=T(n/2)+n2. What is the time complexity?

a)

O(n log n)

b)

O(n2)

c)

O(n3)

d)

O(nlog23)

29.

Scenario: You analyze an algorithm with T(n)=2T(n−1)+1. What is its complexity?

a)

O(n2)

b)

O(2n)

c)

O(n log n)

d)

O(n)

30.

Scenario: An algorithm with recurrence T(n)=2T(n/2)+n fits into which category using the Master Theorem?

a)

Divide and Conquer with O(n log n)

b)

Linear time O(n)

c)

Quadratic time O(n2)

d)

Exponential time O(2n)

31.

Scenario: You need to store hierarchical data like a company’s organizational structure. Which data structure is best suited?

a)

Queue

b)

Binary Tree

c)

Stack

d)

Graph

32.

Scenario: A web browser maintains user navigation history for the back button. What data structure is most appropriate?

a)

Queue

b)

Stack

c)

Binary Tree

d)

Graph

33.

Scenario: A queue is implemented to manage jobs in a printer. Which operation is most efficient in this setup?

a)

Enqueue at the front

b)

Dequeue at the rear

c)

Dequeue at the front

d)

Enqueue at both ends

34.

Scenario: A graph has 1000 vertices and 2000 edges. Which algorithm will likely run faster to find a Minimum Spanning Tree?

a)

Prim’s Algorithm

b)

Kruskal’s Algorithm

c)

Both perform equally

d)

Neither is suitable

35.

Scenario: You have a weighted, connected graph. Which property ensures that Prim’s and Kruskal’s algorithms produce the same MST?

a)

Negative weights

b)

Unique weights

c)

Equal edge weights

d)

Directed graph

36.

Scenario: You are tasked to determine the number of ways to make change for an amount using given coin denominations. Which algorithm design is appropriate?

a)

Backtracking

b)

Greedy Algorithm

c)

Dynamic Programming

d)

Divide and Conquer

37.

Scenario: Solving the matrix chain multiplication problem requires:

a)

Divide and Conquer

b)

Brute Force

c)

Dynamic Programming

d)

Greedy Algorithm

38.

Scenario: The problem of finding the edit distance between two strings can be solved using:

a)

Greedy Algorithm

b)

Dynamic Programming

c)

Divide and Conquer

d)

Brute Force

39.

Scenario: You want to schedule jobs on a single machine to minimize total completion time. Which algorithm type will yield the optimal solution?

a)

Dynamic Programming

b)

Greedy Algorithm

c)

Backtracking

d)

Divide and Conquer

40.

Scenario: A problem requires minimizing the number of platforms needed at a railway station. Which approach should you use?

a)

Brute Force

b)

Dynamic Programming

c)

Greedy Algorithm

d)

Divide and Conquer

41.

Scenario: The Huffman encoding problem can be solved using:

a)

Dynamic Programming

b)

Divide and Conquer

c)

Backtracking

d)

Greedy Algorithm

42.

Scenario: A sorted array is used for searching a number. If the array size doubles, how does the number of comparisons in binary search change?

a)

Doubles

b)

Increases linearly

c)

Increases logarithmically

d)

Remains constant

43.
  1. Scenario: A graph needs to be traversed to find if two nodes are connected. Which search algorithm is more suitable for this?

a)
  1. Binary Search

b)

Linear Search

c)
  1. Depth-First Search

d)

Sorting and Searching

44.
  1. Scenario: In a social network graph, you want to find all people connected to a specific person. Which search algorithm works best?

a)

Binary Search

b)

Breadth-First Search

c)

Depth-First Search

d)

Linear Search

45.
  1. Scenario: You need to sort a nearly sorted array with minimal swaps. Which sorting algorithm will be most efficient?

a)

Quick Sort

b)

Bubble Sort

c)

Insertion Sort

d)

Merge Sort