0% found this document useful (0 votes)
16 views20 pages

Practice MCQ Design and Analysis of Algo

This document contains practice questions related to the design and analysis of algorithms, covering key concepts such as algorithm characteristics, time and space complexity, and various algorithm types. It includes multiple-choice questions that test knowledge on Big O notation, sorting algorithms, search algorithms, and data structures. The questions are structured to reinforce understanding of algorithm efficiency and performance analysis.

Uploaded by

Harsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views20 pages

Practice MCQ Design and Analysis of Algo

This document contains practice questions related to the design and analysis of algorithms, covering key concepts such as algorithm characteristics, time and space complexity, and various algorithm types. It includes multiple-choice questions that test knowledge on Big O notation, sorting algorithms, search algorithms, and data structures. The questions are structured to reinforce understanding of algorithm efficiency and performance analysis.

Uploaded by

Harsh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Practice Questions – Design and Analysis of Algorithm

1. What characteristic ensures an algorithm o Stepwise refinement


will always come to an end? 9. The process of breaking down an
o Finiteness (Correct) algorithm into fundamental steps in a top-
o Definiteness down manner is known as_.
o Input o Pseudocode
o Output o Flowcharts
2. Which characteristic of a good algorithm o Formal Algorithm Description
ensures that each step is clearly defined? o Stepwise Refinement (Correct)
o Finiteness 10. What is the Big O notation used for in
o Definiteness (Correct) algorithm analysis?
o Input o Time complexity (Correct)
o Output o Space complexity
3. An algorithm designed to compute the o Input size
factorial of a number takes a single integer o Output size
as input. Which characteristic does this 11. Which time complexity represents a
represent? constant time algorithm?
o Finiteness o O(n)
o Definiteness o O(log n)
o Input (Correct) o O(1) (Correct)
o Output o O(n^2)
4. The output of a sorting algorithm is a 12. The space complexity of an algorithm that
sorted list. This characteristic is known as_. employs an array of size n to store
o Finiteness intermediate computations is_.
o Definiteness o O(n) (Correct)
o Input o O(log n)
o Output (Correct) o O(1)
5. Which of the following algorithms is more o O(n^2)
efficient for large datasets? 13. In asymptotic analysis, which notation
o Bubble Sort provides the upper bound of the running
o QuickSort (Correct) time?
o Linear Search o Big O (Correct)
o Binary Search o Big Omega
6. Dijkstra's algorithm is commonly used in. o Big Theta
o Search Engines o Little o
o GPS Navigation (Correct) 14. The best-case time complexity of a linear
o E-commerce search algorithm occurs when the target
o Social Media element is_.
7. What type of pseudocode helps o Not in the list
programmers design and convey their o Last in the list
strategies and plans? o First in the list (Correct)
o Formal code o Middle of the list
o Natural language 15. What type of analysis considers the
o Pseudocode (Correct) average performance of an algorithm by
o Flowcharts assuming a probability distribution over
8. Which of the following is used to visually the inputs?
represent an algorithm's steps and o Amortised Analysis
decision points? o Asymptotic Analysis
o Pseudocode o Probabilistic Analysis (Correct)
o Flowcharts (Correct) o Best Case Analysis
o Formal code
1. What is space complexity? o With the depth of recursion
o The time required by an algorithm (Correct)
to execute o Independently of input size
o The maximum amount of space o Logarithmically
required by the algorithm relative 8. How is the space complexity of an
to the input size (Correct) algorithm that creates a new list
o The speed of an algorithm proportional to the input size described?
o The efficiency of an algorithm o O(1)
2. What does Big O notation describe? o O(n) (Correct)
o The space complexity of an o O(log n)
algorithm o O(n^2)
o The efficiency of sorting 9. In the context of algorithm performance,
algorithms what is the significance of time
o The upper bound of time or space complexity?
complexity (Correct) o It measures memory usage
o The lower bound of an algorithm’s o It determines the optimal
efficiency algorithm
3. Which type of space complexity includes o It measures the execution time of
constants and simple variables? an algorithm as input size
o Variable space increases (Correct)
o Dynamic space o It is not important
o Fixed space (Correct) 10. How does the Big O notation help in
o Recursive space analysing algorithms?
4. In time complexity, what does O(1) o By providing the average case
represent? complexity
o Linear time complexity o By describing the lower bound of
o Quadratic time complexity an algorithm’s performance
o Exponential time complexity o By removing constants and lower
o Constant time complexity powers of n to give an upper
(Correct) bound (Correct)
5. What does O(n^2) indicate in terms of o By optimising the algorithm
space complexity? 11. Compare the time complexity of linear
o The space required is constant search and binary search. Which is faster
o The space required grows linearly on average for large datasets?
with the input size o Linear search
o The space required grows o Binary search (Correct)
quadratically with the input size o Both are equal
(Correct) o It depends on the dataset
o The space required grows 12. What does O(log n) time complexity
logarithmically signify?
6. Which space complexity is associated with o The algorithm’s execution time
data structures like arrays that grow with decreases with input size
input size? o The algorithm’s execution time
o Fixed space complexity grows linearly with the input size
o Linear space complexity (Correct) o The algorithm’s execution time
o Quadratic space complexity grows logarithmically with input
o Variable space complexity size (Correct)
7. How does the space complexity of an o The algorithm’s execution time
algorithm increase with a recursion stack? grows quadratically
o Exponentially
13. Why is space complexity analysis crucial in 5. Which notation is used to describe the
embedded systems? average case complexity of an algorithm?
o It is not important o O
o It helps in utilising limited memory o Ω
efficiently (Correct) o Θ (Correct)
o It increases the execution time o o
o It decreases the efficiency of the 6. What does little-oh notation (o) indicate?
system o An asymptotically tight upper
14. Explain the best-case time complexity for a bound
linear search algorithm. o An upper bound that is not
o O(n) asymptotically tight (Correct)
o O(n^2) o The exact bound of an algorithm
o O(log n) o The lower bound of an algorithm
o O(1) (Correct) 7. How is the time complexity of a non-
15. How does the Big O notation assist in recursive algorithm typically analysed?
choosing the right algorithm for a task? o Using recurrence relations
o By ignoring algorithm o Using counting methods (Correct)
performance o Using dynamic programming
o By providing an upper bound on o Using backtracking
the time and space complexity, 8. What is the worst-case time complexity of
helps to compare the efficiency a linear search algorithm?
(Correct) o O(1)
o By focusing only on space o O(log n)
complexity o O(n) (Correct)
o By increasing the complexity o O(n^2)
9. How does binary search achieve a time
1. What does Big-Oh notation (O) represent complexity of O(log n)?
in algorithm analysis? o By checking each element
o Best-case scenario sequentially
o Average-case scenario o By dividing the search interval in
o Worst-case scenario (Correct) half repeatedly (Correct)
o None of the above o By sorting the array first
2. What is the time complexity of bubble sort o By using recursion
in the worst case? 10. What is the time complexity of the
o O(n) recursive algorithm for calculating
o O(log n) factorial?
o O(n^2) (Correct) o O(1)
o O(n log n) o O(log n)
3. What does Omega notation (Ω) signify? o O(n) (Correct)
o Upper bound o O(n^2)
o Lower bound (Correct) 11. How does the recurrence tree method
o Tight bound help in analysing recursive algorithms?
o Average bound o By ignoring the recursive calls
4. In Big-Oh notation, what does O(n log n) o By visualising the structure of
represent? recursive calls and calculating the
o Constant time complexity total cost (Correct)
o Linear time complexity o By solving the problem iteratively
o Log-linear time complexity o By finding the exact solution
(Correct) directly
o Quadratic time complexity
12. Compare Big-Oh and Omega notations. 3. Which search algorithm works efficiently
Which one gives an upper bound on the only on sorted arrays?
running time of an algorithm? o Linear Search
o Big-Oh notation (Correct) o Binary Search (Correct)
o Omega notation o Quick Search
o Both o Depth Search
o Neither 4. What is the main advantage of the KMP
13. What does the Master Theorem provide a algorithm in string matching?
shortcut for? o Uses a hash function
o Solving non-recursive algorithms o Employs a rolling hash
o Solving recurrence relations of the o Avoids unnecessary comparisons
form T(n) = aT(n/b) + f(n) (Correct)
(Correct) o Uses recursion
o Analysing the average case of 5. The time complexity of the Naive pattern-
algorithms matching algorithm is_.
o Finding the exact solution to an o O(n)
algorithm o O(n log n)
14. What is the significance of Θ(n log n) in o O(n*m) (Correct)
the context of merge sort? o O(n^2)
o It indicates that merge sort is less 6. In a Binary Search algorithm, the array
efficient than bubble sort must be_.
o It shows that merge sort has a o Unsorted
quadratic time complexity o Sorted (Correct)
o It indicates that merge sort has an o Partially sorted
average and worst-case time o In descending order
complexity of Θ(n log n) (Correct) 7. Which algorithm uses a priority queue to
o It shows that merge sort is not find the shortest path in a weighted
useful for large inputs graph?
15. Explain why the little-oh notation is useful o Kruskal's Algorithm
for theoretical analysis of algorithms. o Prim's Algorithm
o It provides a tight upper bound o Dijkstra's Algorithm (Correct)
o It provides a loose upper bound o Bellman-Ford Algorithm
(Correct) 8. An adjacency matrix is_.
o It provides the exact running time o Space-efficient for sparse graphs
o It provides the lower bound o Space-efficient for dense graphs
(Correct)
1. Which sorting algorithm uses a divide- o Suitable for trees only
and-conquer approach and has an o Suitable for unconnected graphs
average time complexity of O(n log n)? only
o Bubble Sort 9. What is the time complexity of the Rabin-
o Selection Sort Karp algorithm in the average case?
o Merge Sort (Correct) o O(n) (Correct)
o Insertion Sort o O(n log n)
2. The time complexity of Bubble Sort in the o O(n*m)
worst case is_. o O(n^2)
o O(n) 10. Which graph traversal algorithm uses a
o O(n^2) (Correct) queue data structure?
o O(log n) o Depth-First Search
o O(n log n) o Breadth-First Search (Correct)
o Dijkstra's Algorithm
o Bellman-Ford Algorithm o IsEmpty
11. How does Kruskal's algorithm ensure no 3. In a queue, the operation of adding an
cycles are formed when creating a element at the end is called_.
minimum spanning tree? o Dequeue
o Uses depth-first search o Enqueue (Correct)
o Uses breadth-first search o Front
o Uses union-find data structure o IsEmpty
(Correct) 4. What type of graph has edges with no
o Uses priority queue direction?
12. Which of the following is true about the o Directed Graph
Travelling Salesman Problem (TSP)? o Weighted Graph
o It is solved in polynomial time o Unweighted Graph
o It is considered NP-hard (Correct) o Undirected Graph
o It is solved using bubble sort 5. Which tree has a property that the height
o It has a known efficient solution difference between left and right subtrees
13. What type of data structure is used by the is at most one?
Depth-First Search (DFS) algorithm? o Binary Search Tree
o Queue o AVL Tree (Correct)
o Stack (Correct) o Complete Tree
o Priority Queue o Red-Black Tree
o Heap 6. In a stack, the operation that checks the
14. How does the Boyer-Moore algorithm top element without removing it is called_.
improve the efficiency of pattern o Push
matching? o Pop
o Uses dynamic programming o Peek (Correct)
o Uses a rolling hash o IsEmpty
o Employs the concept of bad 7. Which data structure follows the First In
character heuristic (Correct) First Out (FIFO) principle?
o Uses depth-first search o Stack
15. Describe the process of finding the o Queue (Correct)
shortest path using Dijkstra's algorithm. o Tree
o By removing duplicate calculations o Graph
o By using a priority queue to 8. What is the main advantage of using an
traverse vertices in increasing adjacency list over an adjacency matrix for
order of distance (Correct) representing graphs?
o By using dynamic programming o Quick edge existence checks
o By applying the divide-and- o Space efficiency for sparse graphs
conquer approach (Correct)
o Easy implementation
1. What type of linked list allows o Faster traversal
bidirectional traversal? 9. In a linked list, the operation of accessing
o Singly Linked List each node in sequence is called_.
o Doubly Linked List (Correct) o Insertion
o Circular Linked List o Deletion
o Array List o Traversal (Correct)
2. Which operation in a stack removes the o Sorting
top element? 10. Which type of queue allows elements to
o Push be added or removed from both ends?
o Pop (Correct) o Simple Queue
o Peek o Circular Queue
o Priority Queue o A) Byte
o Deque o B) Element (Correct)
11. How does an AVL tree maintain balance? o C) Node
o By reordering nodes o D) Value
o By ensuring equal number of 4. Which of the following algorithms is an
nodes example of a stable sort?
o Through rotations (Correct) o A) Quick sort
o By height adjustment o B) Merge sort (Correct)
12. What is the main disadvantage of linked o C) Binary search
lists compared to arrays? o D) Selection sort
o Dynamic size 5. What type of graph is required for
o Extra memory for pointers topological sort?
(Correct) o A) Undirected graph
o Easy insertion/deletion o B) Directed acyclic graph (Correct)
o Fast access time o C) Weighted graph
13. Which graph traversal algorithm uses a o D) Unweighted graph
queue? 6. The time complexity of merge sort is_.
o Depth-First Search o A) O(n)
o Breadth-First Search (Correct) o B) O(n^2)
o Dijkstra's Algorithm o C) O(n log n) (Correct)
o Kruskal's Algorithm o D) O(log n)
14. What property of B Trees makes them 7. In a quick sort, the element that partitions
efficient for databases? the array is called_.
o Height-Balanced (Correct) o A) Median
o Binary Search o B) Pivot (Correct)
o Limited children o C) Middle
o Recursive structure o D) Divider
15. In a priority queue, how are elements 8. Which of the following is NOT an
dequeued? advantage of the divide and conquer
o In random order approach?
o Based on their value o A) Efficiency
o In the order of their priority o B) Parallelism
(Correct) o C) Simplicity
o First come first serve o D) Overhead
9. What is the main disadvantage of quick
1. What is the principle behind the binary sort?
search algorithm? o A) It is not efficient
o A) Divide and merge o B) It is not stable (Correct)
o B) Divide and conquer (Correct) o C) It uses extra space
o C) Combine and sort o D) It is not versatile
o D) Merge and split 10. Which operation is NOT typically
2. The time complexity of the binary search performed on data structures?
is_. o A) Insertion
o A) O(n) o B) Deletion
o B) O(n^2) o C) Traversal
o C) O(log n) (Correct) o D) Translation
o D) O(n log n) 11. How does binary search reduce the search
3. In merge sort, the array is recursively space?
divided until each subarray contains a o A) By merging subarrays
single_.
o B) By splitting the list in half o Maximise the number of coins
(Correct) used
o C) By sorting the array o Use the smallest denominations
o D) By combining elements o Use the largest denominations
12. In merge sort, what happens after dividing 4. Which of the following problems can be
the array into subarrays? solved optimally using a greedy
o A) Subarrays are discarded algorithm?
o B) Subarrays are compared o 0/1 Knapsack Problem
o C) Subarrays are merged (Correct) o Coin Change Problem
o D) Subarrays are multiplied o Fractional Knapsack Problem
13. Which of the following is true about quick (Correct)
sort's average time complexity? o Traveling Salesman Problem
o A) O(n) 5. What is the first step in solving the
o B) O(n^2) fractional knapsack problem using a
o C) O(log n) greedy algorithm?
o D) O(n log n) o Divide the items into two groups
14. Why is the divide and conquer approach o Calculate the value-to-weight ratio
suitable for parallel computing? of each item (Correct)
o A) It merges results quickly o Sort items by weight
o B) It splits tasks into independent o Select the heaviest item
subproblems (Correct) 6. The coin change problem can sometimes
o C) It uses less memory be solved optimally using a greedy
o D) It simplifies code approach if_.
15. What is the principle of topological sort? o The coin denominations are all
o A) Sort vertices in decreasing order multiples of each other
o B) Sort vertices to minimize edges o The denominations include a 1-
o C) Arrange vertices so each unit coin (Correct)
directed edge uv has u before v o The denominations are all prime
(Correct) numbers
o D) Arrange vertices by weight o The denominations are random
7. In the fractional knapsack problem, how
1. What is the key principle behind the do you handle an item that cannot fully fit
greedy algorithm? into the remaining capacity of the
o Divide and conquer knapsack?
o Use dynamic programming o Discard it
o Make the locally optimal choice at o Take a fraction of it (Correct)
each stage (Correct) o Skip it
o Use backtracking o Replace it with another item
2. Which property allows a greedy algorithm 8. What does the term 'optimal substructure'
to reach a global optimum by making imply in the context of greedy algorithms?
local optimum decisions? o The solution to a problem can be
o Optimal substructure constructed efficiently
o Dynamic programming o Each step must be solved
o Greedy choice property (Correct) recursively
o Divide and conquer o The problem can be divided into
3. In the coin change problem, what is the subproblems that are solved
primary goal? independently
o Minimise the number of coins o An optimal solution to the
used (Correct) problem contains optimal
solutions to subproblems
9. Why might a greedy algorithm fail to 15. How can the limitations of the greedy
produce an optimal solution? approach be addressed in the coin change
o It takes too long to execute problem?
o It does not consider the future o By using a larger coin set
consequences of its decisions o By using dynamic programming
(Correct) (Correct)
o It uses too much memory o By ignoring the largest
o It is too complex to implement denomination
10. Compare the greedy method and dynamic o By using only even denominations
programming in terms of solution
optimality for the coin change problem. 1. What is a minimum cost spanning tree
o Greedy is always optimal, dynamic (MCST)?
is not o A tree that connects all vertices
o Dynamic is always optimal, greedy with the maximum total weight
is not (Correct) o A tree that connects all vertices
o Both are always optimal with the minimum total weight
o Neither is always optimal (Correct)
11. What is a major disadvantage of the o A tree with the maximum number
greedy algorithm when applied to the coin of edges
change problem? o A tree that only includes leaf
o It is too slow nodes
o It uses too much memory 2. Which algorithm starts from an arbitrary
o It does not always produce the vertex and grows the spanning tree by
optimal solution (Correct) selecting the minimum weight edge?
o It is difficult to implement o Dijkstra’s Algorithm
12. In Dijkstra's algorithm, what strategy is o Bellman-Ford Algorithm
used to find the shortest path in a graph? o Prim’s Algorithm (Correct)
o Depth-first search o Kruskal’s Algorithm
o Breadth-first search 3. What data structure is typically used in
o Greedy strategy (Correct) Prim's Algorithm for efficient
o Backtracking implementation?
13. How does the greedy algorithm for the o Stack
fractional knapsack problem ensure an o Queue
optimal solution? o Priority Queue (Correct)
o By using dynamic programming o Array
o By ensuring the largest item is 4. Kruskal’s algorithm primarily uses which
always selected data structure to manage the merging of
o By maximising the value-to-weight trees?
ratio (Correct) o Priority Queue
o By dividing the knapsack into o Disjoint-Set (Correct)
smaller sections o Stack
14. Explain why a greedy algorithm might be o Queue
preferred over dynamic programming in 5. What is the key difference between Prim’s
certain scenarios. and Kruskal’s Algorithms?
o It always produces better results o Prim’s starts with edges, Kruskal’s
o It is easier to implement and faster starts with vertices
(Correct) o Prim’s starts with vertices, Kruskal’s
o It requires less memory starts with edges (Correct)
o It can handle more complex o Prim’s is used for directed graphs,
problems Kruskal’s for undirected
o Prim’s is faster than Kruskal’s o To manage disjoint sets and check
6. In Kruskal’s Algorithm, how are the edges for cycles (Correct)
sorted? o To calculate edge weights
o By weight in descending order 13. Compare the space complexity of Prim’s
o By weight in ascending order and Kruskal’s Algorithms.
(Correct) o Prim’s is higher
o By vertex number o Kruskal’s is higher
o Randomly o Both have the same space
7. What is the goal of the single source coin complexity (Correct)
change problem? o Depends on the graph type
o Maximise the number of coins 14. Explain why dynamic programming is
used effective for the single source coin change
o Minimise the number of coins problem.
used (Correct) o It sorts the coins by value
o Use the largest coin o It ensures the fewest coins are
denominations first used by checking all combinations
o Use the smallest coin (Correct)
denominations first o It uses a priority queue
8. Which algorithm is generally more o It uses recursion
efficient for dense graphs? 15. Describe an application of minimum cost
o Dijkstra’s Algorithm spanning trees in network design.
o Bellman-Ford Algorithm o Maximising the length of cables
o Prim’s Algorithm (Correct) o Minimising the length of cables
o Kruskal’s Algorithm required to connect all points
9. What is involved in the dynamic (Correct)
programming approach to the coin o Maximising the number of nodes
change problem? o Using the largest possible cables
o Using recursion only
o Breaking the problem into smaller 1. What is the primary objective of Dijkstra's
subproblems (Correct) Algorithm?
o Sorting the coins by value o To find the shortest path from a
o Using a greedy approach single source vertex to all other
10. Why might Kruskal’s Algorithm be vertices in a weighted graph
preferred for sparse graphs? (Correct)
o It is simpler to implement o To find the longest path in a graph
o It uses more memory o To find the shortest path in an
o It is faster due to fewer edges unweighted graph
(Correct) o To find the maximum spanning
o It uses a greedy approach tree
11. How does Prim’s Algorithm ensure the 2. In graph theory, what is a vertex?
inclusion of the least costly connection at o A set of edges
each step? o A node where edges meet
o By checking all possible edges (Correct)
o By using a priority queue (Correct) o A weighted edge
o By sorting all edges beforehand o A subgraph
o By using recursion 3. What is an edge in a graph?
12. In Kruskal’s Algorithm, what is the role of o A node where vertices meet
the union-find data structure? o A line connecting two vertices
o To manage the priority queue (Correct)
o To perform edge sorting o A type of graph
o A subgraph 10. How does Dijkstra's Algorithm ensure it
4. Which data structure is used in Dijkstra's always finds the shortest path to the
Algorithm to select the next vertex with current vertex?
the shortest tentative distance? o By checking all possible paths
o Stack o By using a priority queue to select
o Queue the vertex with the shortest
o Priority Queue (Correct) tentative distance (Correct)
o Linked List o By updating the distance values to
5. Why must all edge weights be non- ∞
negative in Dijkstra's Algorithm? o By ignoring all visited vertices
o To ensure the algorithm runs 11. What is a limitation of Dijkstra's
faster Algorithm?
o To prevent the algorithm from o It only works with unweighted
getting stuck in a loop graphs
o To ensure the algorithm correctly o It cannot handle negative edge
finds the shortest path (Correct) weights (Correct)
o To reduce memory usage o It is too slow for small graphs
6. What is the time complexity of Dijkstra's o It always finds the longest path
Algorithm when implemented using a 12. How does the priority queue improve the
binary heap? efficiency of Dijkstra's Algorithm?
o O(V^2) o By reducing the number of vertices
o O(E log V) o By sorting the vertices by their
o O((V + E) log V) (Correct) names
o O(E^2) o By always selecting the vertex with
7. In the initialization step of Dijkstra's the smallest tentative distance
Algorithm, what is the distance value (Correct)
assigned to the starting vertex? o By increasing the number of edges
o 0 (Correct) 13. Compare Dijkstra's Algorithm with the
o ∞ Bellman-Ford Algorithm. Which one can
o 1 handle negative edge weights?
o -1 o Dijkstra's Algorithm
8. Which of the following is an application of o Bellman-Ford Algorithm (Correct)
Dijkstra's Algorithm? o Both
o Finding the longest path in a o Neither
graph 14. Explain how the A* Algorithm enhances
o Network routing (Correct) Dijkstra's Algorithm.
o Finding a minimum spanning tree o By using a stack instead of a
o Sorting a list of numbers priority queue
9. During the iteration step of Dijkstra's o By using heuristics to guide the
Algorithm, what happens to the current search (Correct)
vertex? o By ignoring all edges
o It is marked as visited and o By increasing the number of
removed from the set of unvisited iterations
vertices (Correct) 15. What is the role of the priority queue in
o It is marked as unvisited and optimizing Dijkstra's Algorithm?
added to the set of visited vertices o To sort the edges by their weight
o Its distance value is set to ∞ o To keep track of visited vertices
o It is skipped in the next iteration o To select the vertex with the
smallest tentative distance
(Correct)
o To increase the graph size 7. In Huffman coding, how is the priority
queue used?
1. What is the primary goal of Huffman o To store the longest codes
coding? o To keep track of the nodes with
o To maximise data size the least frequency (Correct)
o To reduce the overall size of data o To sort data alphabetically
by assigning shorter codes to o To merge all nodes
more frequent items (Correct) 8. What is the advantage of Huffman coding
o To create redundant data in file compression?
o To increase transmission time o It increases file size
2. In Huffman coding, what is a binary tree o It reduces file size (Correct)
used for? o It slows down transmission
o To sort data o It creates redundant data
o To create a hierarchical structure 9. How does Huffman coding handle
of nodes frequently occurring data items?
o To build a tree with the data items o By assigning them longer codes
as the terminal nodes and the o By ignoring them
binary code for each item as the o By assigning them shorter codes
path from the root (Correct) (Correct)
o To merge data items o By duplicating them
3. Which property ensures that no code is a 10. Why is Huffman coding considered
prefix of another code in Huffman coding? efficient in data compression?
o Suffix codes o Because it uses fixed-length codes
o Prefix codes (Correct) o Because it uses variable-length
o Redundant codes codes based on frequency
o Sequential codes (Correct)
4. How are the nodes with the lowest o Because it compresses all data
frequencies handled in the Huffman Tree equally
construction? o Because it only works with small
o They are merged to form a new datasets
node (Correct) 11. What is the primary use of Huffman
o They are deleted coding in telecommunications?
o They are assigned the longest o To increase the amount of data
codes transmitted
o They are left unchanged o To minimise the volume of data to
5. What principle is Huffman coding based be sent (Correct)
on? o To create redundant signals
o Assigning longer codes to o To slow down communication
frequent items 12. How does the frequency calculation step
o Assigning shorter codes to in Huffman coding improve compression
frequent items (Correct) efficiency?
o Assigning random codes to items o By ignoring rare items
o Assigning equal codes to all items o By prioritising frequent items for
6. What is the initial step in constructing a shorter codes (Correct)
Huffman Tree? o By assigning random codes
o Merging nodes o By duplicating frequent items
o Calculating frequencies (Correct) 13. Compare Huffman coding with other data
o Sorting data items compression techniques in terms of
o Encoding data efficiency.
o Huffman coding is less efficient
o Huffman coding is equally efficient 5. Which property of a heap ensures that
o Huffman coding is more efficient every level is filled except possibly the
for variable-length coding last?
(Correct) o Heap property
o Huffman coding is only efficient o Complete binary tree property
for fixed-length coding (Correct)
14. What is the compression ratio in Huffman o Balance property
coding? o Priority property
o The ratio of the original data size 6. What is the time complexity of the
to the compressed data size insertion operation in a heap?
o The ratio of the compressed data o O(n)
size to the original data size o O(log n) (Correct)
(Correct) o O(n log n)
o The ratio of redundant data to the o O(1)
original data size 7. During deletion in a heap, what happens
o The ratio of the longest code to after removing the root node?
the shortest code o The heap is left empty
15. Discuss the significance of prefix codes in o The last node is moved to the root
Huffman coding. and sifted down (Correct)
o They ensure unique and o A new root is randomly selected
unambiguous decoding (Correct) o The tree is restructured completely
o They increase data size 8. Which operation transforms a binary tree
o They are less efficient into a heap?
o They create redundancy o Insertion
o Deletion
1. What type of binary tree satisfies the heap o Sorting
property? o Heapify
o Complete binary tree (Correct) 9. What is the parent index of a node at
o Balanced binary tree index i in a heap implemented as an array?
o Binary search tree o i+1
o AVL tree o 2i
2. In a max-heap, the parent node is always o 2i+1
___ than its child nodes. o (i-1)/2
o Smaller 10. How does heap sort begin its sorting
o Equal process?
o Larger (Correct) o By creating a min-heap
o Unrelated o By creating a max-heap (Correct)
3. What is the root element in a min-heap? o By creating a balanced tree
o The largest element o By creating an AVL tree
o The smallest element (Correct) 11. What is the space complexity of heap sort?
o The middle element o O(n)
o A random element o O(log n)
4. How is a new element added to a max- o O(n log n)
heap? o O(1)
o At the root 12. Why is heap sort considered more efficient
o At the last position and then than bubble sort?
moved up (Correct) o Because it has a lower time
o At the first position and then complexity (Correct)
moved down o Because it is easier to implement
o Randomly
o Because it sorts elements 4. What property of dynamic programming
randomly states that a problem can be broken into
o Because it requires more space overlapping subproblems?
13. Compare the time complexity of heap sort o A) Optimal substructure
with quick sort in the worst case. o B) Greedy choice property
o Heap sort is O(n^2), quick sort is o C) Overlapping subproblems
O(n log n) (Correct)
o Both are O(n log n) o D) Divide and conquer
o Heap sort is O(n log n), quick sort 5. How does dynamic programming improve
is O(n^2) (Correct) the efficiency of the Fibonacci sequence
o Both are O(n^2) calculation?
14. What is the advantage of using heap sort o A) By using recursion only
over quick sort? o B) By storing the results of
o It is faster in practice subproblems (Correct)
o It requires less memory o C) By sorting the results
o It has a stable sort o D) By using a greedy approach
o It has a predictable worst-case 6. In the knapsack problem, what is the goal?
time complexity o A) To minimise the total value
15. Explain why heap sort is not a stable o B) To maximise the total weight
sorting algorithm. o C) To maximise the total value
o It changes the order of equal without exceeding the capacity
elements (Correct) (Correct)
o It does not change the order of o D) To minimise the number of
equal elements items
o It sorts elements in place 7. What technique in dynamic programming
o It uses extra space for sorting involves storing solutions of subproblems
in a table and building up the solution?
1. What is the essence of dynamic o A) Recursion
programming? o B) Tabulation (Correct)
o A) Using divide and conquer o C) Memoisation
o B) Saving solutions to o D) Sorting
subproblems (Correct) 8. In dynamic programming, what is meant
o C) Randomly solving problems by 'optimal substructure'?
o D) Using only recursion o A) The ability to solve problems
2. What is the primary technique used in independently
dynamic programming to avoid redundant o B) The ability to solve problems
calculations? recursively
o A) Recursion o C) The ability to solve a problem
o B) Memoisation (Correct) using the best solutions to
o C) Sorting subproblems (Correct)
o D) Backtracking o D) The ability to use random
3. In dynamic programming, what is solutions
'tabulation'? 9. How does the dynamic programming
o A) A top-down approach approach to the longest common
o B) A bottom-up approach subsequence problem improve efficiency?
(Correct) o A) By using exponential time
o C) A random approach complexity
o D) A binary approach o B) By recalculating subproblems
multiple times
o C) By storing the results of o C) By incorporating the stored
subproblems in a table (Correct) results of subproblems (Correct)
o D) By ignoring previous results o D) By using a random approach
10. Why is the matrix chain multiplication
problem suitable for dynamic 1. What is transitive closure in graph theory?
programming? o Finding the shortest path between
o A) Because it cannot be divided nodes
into subproblems o Determining if a path exists
o B) Because it has a simple recursive between nodes
solution o Ensuring a direct connection exists
o C) Because it has overlapping between nodes if a path exists
subproblems and optimal indirectly (Correct)
substructure (Correct) o Calculating the weight of the
o D) Because it requires sorting heaviest edge
11. Compare memoisation and tabulation in 2. What does Warshall’s Algorithm compute?
dynamic programming. Which one is a o Shortest path between two nodes
bottom-up approach? o Minimum spanning tree
o A) Memoisation o Transitive closure of a directed
o B) Tabulation (Correct) graph (Correct)
o C) Both o Maximum flow in a network
o D) Neither 3. What is the first step in Warshall’s
12. What is the time complexity of the Algorithm?
dynamic programming solution to the o Iteration through vertices
knapsack problem? o Initialisation with the adjacency
o A) O(n) matrix (Correct)
o B) O(n log n) o Calculation of shortest paths
o C) O(n^2) o Updating the distance matrix
o D) O(nW) (Correct) 4. Which data structure is primarily used in
13. Discuss the significance of storing Warshall’s Algorithm?
subproblem solutions in dynamic o Binary tree
programming. o Stack
o A) It increases memory usage o Queue
o B) It avoids redundant calculations o Adjacency matrix (Correct)
(Correct) 5. What is the main purpose of the adjacency
o C) It simplifies code matrix in Warshall’s Algorithm?
o D) It reduces the time complexity o To store distances between nodes
14. How does dynamic programming ensure o To represent the presence or
the efficiency of algorithms compared to absence of edges between vertices
traditional recursion? (Correct)
o A) By using more memory o To list all nodes in the graph
o B) By increasing time complexity o To calculate the number of edges
o C) By reducing redundant 6. In the transitive closure, if node A is
calculations (Correct) connected to node B and node B to node
o D) By simplifying the problem C, what does it imply?
15. Explain the process of constructing an o Node A is not connected to node
optimal solution in dynamic programming. C
o A) By solving all subproblems o Node C is connected to node A
independently o Node A is connected to node C
o B) By ignoring subproblem (Correct)
solutions
o Node B is not connected to node 14. How is transitive closure useful in
A database query optimisation?
7. How does Warshall’s Algorithm handle o It reduces query time by
intermediate vertices? precomputing reachability
o Ignores them (Correct)
o Uses them to update the o It increases the number of queries
reachability matrix (Correct) o It slows down the database
o Deletes them o It simplifies the database structure
o Only considers the initial vertex 15. Explain why Warshall’s Algorithm is
8. Which step follows the initialisation in suitable for teaching graph reachability.
Warshall’s Algorithm? o It is simple and has clear steps
o Completion (Correct)
o Deletion o It is complex and difficult to
o Iteration (Correct) understand
o Sorting o It requires advanced knowledge
9. What is the time complexity of Warshall’s o It is only theoretical
Algorithm?
o O(n) 1. What does Floyd’s Algorithm compute?
o O(n^2) o Maximum flow in a network
o O(n log n) o Shortest paths in a weighted graph
o O(n^3) (Correct) (Correct)
10. How does Warshall’s Algorithm update the o Minimum spanning tree
reachability matrix? o Longest paths in a graph
o By recalculating paths directly 2. What is the primary goal of an Optimal
o By considering paths through Binary Search Tree (OBST)?
intermediate vertices (Correct) o Minimise the number of nodes
o By ignoring intermediate paths o Maximise the search time
o By calculating the longest paths o Minimise the search cost (Correct)
11. What is the space complexity of Warshall’s o Maximise the tree height
Algorithm? 3. In the 0/1 Knapsack Problem, what is the
o O(n) objective?
o O(n^2) (Correct) o Minimise the weight
o O(n log n) o Maximise the number of items
o O(n^3) o Maximise the total value without
12. Why is Warshall’s Algorithm considered exceeding weight capacity
inefficient for large graphs? (Correct)
o It has high space complexity o Minimise the total value
o It cannot handle negative weights 4. Which algorithm can handle graphs with
o It has cubic time complexity negative weight edges?
(Correct) o Dijkstra’s Algorithm
o It requires sorting o Floyd’s Algorithm
13. Compare Warshall’s Algorithm with the o Bellman-Ford Algorithm (Correct)
Floyd-Warshall Algorithm. What is the key o Kruskal’s Algorithm
difference? 5. What is the goal of the Travelling Sales
o Warshall's algorithm handles Person problem?
negative weights o Minimise the number of cities
o Floyd-Warshall calculates the visited
shortest paths (Correct) o Maximise the travel cost
o Warshall's algorithm is faster
o Floyd-Warshall is less efficient
o Visit all cities with the shortest o O(VE) (Correct)
possible route and return to the o O(E log V)
starting point (Correct) 13. Compare Floyd’s Algorithm and Bellman-
o Maximise the distance travelled Ford Algorithm in terms of their
6. In network reliability design, what is a key application. Which one is used for all pairs
component? of shortest paths?
o Redundancy (Correct) o Floyd’s Algorithm (Correct)
o Minimisation of connections o Bellman-Ford Algorithm
o Single point of failure o Both
o Random connections o Neither
7. How does Floyd’s Algorithm update the 14. What is the disadvantage of using the
shortest path estimate? Travelling Sales Person problem for large
o By recalculating the entire path datasets?
o By iteratively updating the o It is easy to solve
distance matrix (Correct) o It has exponential time complexity
o By deleting unnecessary paths (Correct)
o By using a stack o It always gives the wrong solution
8. What technique is used to construct an o It ignores distances
Optimal Binary Search Tree? 15. Discuss the significance of redundancy in
o Sorting network reliability design.
o Divide and conquer o It reduces system complexity
o Dynamic programming (Correct) o It increases the risk of failure
o Greedy algorithm o It ensures continuous operation
9. How does the Bellman-Ford Algorithm despite failures (Correct)
handle negative weight cycles? o It minimises costs
o By ignoring them
o By detecting and reporting them 1. What is the main goal of the N-Queens
(Correct) problem?
o By adding extra weight o To place N queens on an N x N
o By recalculating distances chessboard such that no two
10. In the 0/1 Knapsack Problem, what does queens threaten each other
the matrix V[i][w] represent? (Correct)
o The maximum value that can be o To place N queens on an N x N
obtained with the first i items and chessboard such that all queens
capacity w (Correct) are in the same row
o The weight of item i o To place N queens on an N x N
o The total value of all items chessboard in a straight line
o The number of items o To place N queens on an N x N
11. How is the distance matrix updated in chessboard in a diagonal line
Floyd’s Algorithm? 2. In the sum of subsets problem, what is the
o By adding new edges objective?
o By comparing all possible paths o To find a subset of a given set that
through intermediate vertices adds up to a specific product
(Correct) o To find all subsets of a given set
o By removing vertices that add up to a specific sum
o By recalculating weights (Correct)
12. What is the time complexity of the o To find the largest subset of a
Bellman-Ford Algorithm? given set
o O(n) o To find the smallest subset of a
o O(n^2) given set
3. What is the main challenge in the graph o Start with the first vertex and
colouring problem? assign the first colour (Correct)
o Ensuring no two vertices have the o Remove all edges
same colour o Add extra vertices
o Minimising the number of edges 9. How does the backtracking algorithm
o Maximising the number of colours handle conflicts in the graph colouring
used problem?
o Ensuring no two adjacent vertices o By ignoring them
have the same colour (Correct) o By assigning the same colour
4. What is a Hamiltonian cycle? o By backtracking to the previous
o A cycle that visits each vertex of a vertex and trying a different colour
graph exactly once and returns to (Correct)
the starting vertex (Correct) o By removing the vertex
o A path that visits each vertex 10. In the Hamiltonian cycle problem, what
exactly once happens if a vertex is revisited?
o A cycle that visits each vertex of a o The algorithm continues
graph exactly twice o The cycle is considered complete
o A cycle that skips vertices o The algorithm backtracks to the
randomly previous vertex (Correct)
5. Which of the following problems can be o The vertex is removed from the
solved using backtracking? graph
o N-Queens problem (Correct) 11. What is the time complexity of the
o Bubble sort backtracking algorithm for the N-Queens
o Linear search problem?
o Binary search o O(N)
6. How does the backtracking approach work o O(N^2)
in solving the N-Queens problem? o O(N!) (Correct)
o By placing queens randomly on o O(2^N)
the board 12. Compare the backtracking approach to
o By placing queens row by row and the brute-force approach in solving
backtracking when conflicts combinatorial problems. Which one is
develop (Correct) more efficient?
o By placing all queens in one o Backtracking is more efficient
column because it eliminates unnecessary
o By placing queens in a circular searches (Correct)
manner o Brute-force is more efficient
7. In the sum of subsets problem, when does because it tries all possibilities
the algorithm backtrack? o Both are equally efficient
o When the sum of the current o Neither is efficient
subset exceeds the target sum or 13. Why is the sum of subsets problem
all elements are included (Correct) considered challenging?
o When the sum of the current o Because it involves division
subset is less than the target sum operations
o When the subset is empty o Because it requires sorting
o When all subsets are found o Because it involves the
8. What is the first step in the backtracking enumeration of all subsets, which
approach to solve the graph colouring is an exponential time process
problem? (Correct)
o Colour all vertices with the same o Because it requires constant space
colour
14. What is the main advantage of using 5. What is the primary objective of the
backtracking for the Hamiltonian cycle Travelling Salesperson Problem?
problem? o Minimise the number of cities
o It guarantees finding the shortest visited
path o Minimise the travel cost or
o It can handle large graphs distance by visiting each city
efficiently exactly once and returning to the
o It systematically explores all starting city (Correct)
possible cycles (Correct) o Maximise the number of visits
o It ignores redundant paths o Maximise the travel cost
15. Discuss the significance of backtracking in 6. In the branch and bound method, what
solving the graph colouring problem. does 'bounding' involve?
o It reduces the number of edges o Eliminating subproblems
o It ensures all vertices have the o Estimating the minimum cost of
same colour subproblems (Correct)
o It helps in finding the chromatic o Adding new tasks
number by exploring all possible o Reassigning agents
colourings systematically (Correct) 7. How is the lower bound used in the
o It increases the number of colours branch and bound approach for the
used assignment problem?
o To ignore the optimal solution
1. What is the primary goal of the o To estimate the minimum cost of
assignment problem? unassigned tasks (Correct)
o Maximising the total cost o To maximise the cost
o Minimising the total time or cost o To assign tasks randomly
(Correct) 8. In the TSP, what does a 'partial tour' refer
o Maximising the number of agents to?
o Minimising the number of tasks o A complete tour
2. In the branch and bound method, what is o A tour that includes only some of
the purpose of pruning? the cities (Correct)
o Adding new tasks o A tour with no cities
o Eliminating subproblems with o A tour with all cities visited twice
bounds higher than the current 9. What is the first step in the branch and
best solution (Correct) bound method for the knapsack problem?
o Increasing the search space o Filling the knapsack with the
o Reassigning tasks heaviest items
3. What is a key characteristic of the 0/1 o Starting with an empty knapsack
knapsack problem? and calculating the initial upper
o Items can be partially taken bound (Correct)
o Each item can either be taken or o Sorting the items by weight
not taken (Correct) o Ignoring the weight of items
o The knapsack can be resized 10. How does the branch and bound method
o Items must be taken in pairs ensure optimality in the TSP?
4. Which algorithm is used to solve the o By visiting cities randomly
Travelling Salesperson Problem (TSP)? o By considering and pruning all
o Dijkstra's Algorithm possible tours (Correct)
o Bellman-Ford Algorithm o By only considering the nearest
o Branch and Bound (Correct) cities
o Floyd-Warshall Algorithm o By maximising the distance
11. What is the mathematical formulation o Either included or excluded
used to represent the assignment (Correct)
problem? o Ignored
o Linear equations 3. What does LC stand for in the LC Branch
o Binary variables (Correct) and Bound method?
o Non-linear equations o Least Cost (Correct)
o Differential equations o Linear Combination
12. Compare the branch and bound method o Limited Capacity
with the greedy algorithm for the o Large Constraint
knapsack problem. Which one guarantees 4. Which step in the LC Branch and Bound
to find the optimal solution? method involves calculating upper and
o Greedy algorithm lower bounds for subproblems?
o Branch and Bound (Correct) o Branching
o Both o Bounding (Correct)
o Neither o Pruning
13. What is the time complexity of the branch o Termination
and bound algorithm for the assignment 5. What is the main goal of pruning in the LC
problem? Branch and Bound method?
o Polynomial o To increase the number of
o Exponential (Correct) subproblems
o Linear o To eliminate subproblems that
o Logarithmic cannot yield a better solution than
14. Why is the branch and bound method the current best (Correct)
preferred for solving large TSP instances? o To add more items to the
o It is the fastest method knapsack
o It guarantees the optimal solution o To randomly select items
by exploring and pruning all 6. In the context of the Knapsack Problem,
possible tours (Correct) what is the significance of the term
o It uses the least memory 'fractional knapsack'?
o It is the simplest method o Items can be divided and included
15. How does the branch and bound method partially (Correct)
for the knapsack problem handle items o Items must be included fully
that exceed the knapsack's capacity? o Items are ignored
o By including them o Items are sorted randomly
o By partially including them 7. How is the initial bound calculated in the
o By excluding them (Correct) LC Branch and Bound method?
o By resizing the knapsack o Using the total weight of items
o Using the total value of items
1. What is the primary objective of the o Using the fractional knapsack
Knapsack Problem? approach (Correct)
o To maximise the weight of items o Using the number of items
o To minimise the number of items 8. During the branching step, what are the
o To maximise the total value of two branches created for each item?
items without exceeding the o Include the item and exclude the
weight capacity (Correct) item
o To select items randomly o Include the item and divide the
2. In the 0/1 Knapsack Problem, each item item (Correct)
can be. o Exclude the item and divide the
o Included multiple times item
o Included partially
o Combine the item and split the 15. Describe how the LC Branch and Bound
item method can be optimised using heuristics.
9. In the LC Branch and Bound method, what o By ignoring bounds
happens if the bound of a branch is less o By randomly selecting branches
than the current best solution? o By applying heuristics to guide the
o The branch is included search process (Correct)
o The branch is pruned (Correct) o By increasing the number of
o The branch is divided branches
o The branch is ignored
10. What is the time complexity of the LC
Branch and Bound method in the worst
case?
o O(n)
o O(n^2)
o O(2^n) (Correct)
o O(n!)
11. Compare the LC Branch and Bound
method with the Dynamic Programming
approach for the Knapsack Problem.
Which one is more memory-intensive?
o LC Branch and Bound
o Dynamic Programming (Correct)
o Both are equally memory-intensive
o Neither is memory-intensive
12. Why is the LC Branch and Bound method
considered efficient despite its worst-case
time complexity?
o Because it always finds the
solution quickly
o Because effective pruning reduces
the number of branches explored
(Correct)
o Because it ignores subproblems
o Because it uses a greedy approach
13. What is a major advantage of the LC
Branch and Bound method?
o It provides an optimal solution
(Correct)
o It is very fast in all cases
o It uses no memory
o It always prunes all branches
14. Explain the role of the bounding step in
the LC Branch and Bound method.
o To add more items to the
knapsack
o To eliminate subproblems based
on their calculated bounds
(Correct)
o To sort items by weight
o To ignore bounds

You might also like