Sample Paper - CS502
Sample Paper - CS502
FINALTERM EXAMINATION
Fall 2022
CS502 - Fundamentals of Algorithms
Time: 90 min
Marks: 60
a) Search Problem
b) Computational Problem
c) Optimization Problem
d) Parallel Computation Problem
a) Search Problem
b) Computational Problem
c) Optimization Problem
d) Parallel Computation Problem
a) Greedy algorithm
b) 2 D dynamic programming
c) 1 D dynamic programming
d) Divide and conquer
You are given a knapsack that can carry a maximum weight of 60. There are 4 items with weights {20,
30, 40, 70} and values {70, 80, 90, 200}. What is the maximum value of the items you can carry using
the knapsack?
a) 160
b) 200
c) 170
d) 90
Which of the following algorithms is the best approach for solving Huffman codes?
a) exhaustive search
b) greedy algorithm
c) brute force algorithm
d) divide and conquer algorithm
From the following given tree, what is the computed codeword for ‘c’?
a) 111
b) 101
c) 110
d) 011
Question No: 8 (Marks: 01) - Please choose the correct option
Fractional knapsack problem is solved most efficiently by which of the following algorithm?
A) Scheduling Problem
B) Search Problem
C) Computational Problem
D) Non Computational Problem
a) O(N)
b) O(S)
c) O(N2)
d) O(S*N)
Question No: 14 (Marks: 01) - Please choose the correct option
What is the key difference between the 0/1 knapsack problem and the fractional knapsack problem?
a) The 0/1 knapsack problem allows items to be broken into parts, while the fractional knapsack
problem does not
b) The 0/1 knapsack problem requires items to be taken in their entirety, while the fractional
knapsack problem allows items to be taken in fractional amounts
c) The 0/1 knapsack problem only allows items to be taken in whole numbers, while the fractional
knapsack problem allows items to be taken in any amount
d) The 0/1 knapsack problem is much easier to solve than the fractional knapsack problem
a) Greater than
b) Less than or greater than
c) Subset of
d) Equal to
The number of vertices in a Minimum Spanning Tree (MST) is _____________ the number of vertices
in the original graph.
a) Less than
b) Greater than
c) Subset of
d) Equal to
Kruskal’s algorithm is used for computing Minimum Spanning Tree (MST) and is based on
____________ strategy.
a) Dynamic Programming
b) Greedy
c) Divide and Conquer
d) Backtracking
In Dijkstra algorithm the estimate of source vertex (i.e. s) is represented by d[s] and its value is
____________
a) Equal to zero
b) Greater than zero
c) Less than zero
d) Equal to one
If a shortest paths algorithm allow negative cost cycle, then the algorithm will compute
Which algorithm does not allow negative weights while computing the shortest paths in a directed
graph?
a) Dijkstra’s algorithm
b) Floyd-Warshall Algorithm
c) Bellman Ford
d) Johnson
Floyd Warshall’s algorithm is used for computing shortest paths and is based on ____________
strategy.
a) Dynamic Programming
b) Greedy
c) Divide and Conquer
d) Backtracking
What is the time stamp structure used in Depth First Search (DFS)?
a) Inorder traversal time stamp
b) Preorder traversal time stamp
c) Postorder traversal time stamp
d) Level-order traversal time stamp
Answer
Write down at least three real life applications of Minimum Spanning Tree (MST).
___________________________________________________________
Answer
Answer
Answer
Answer
What is an adjacency matrix and how is it used to represent the connections between vertices in a graph?
Answer
Question No: 47 (Marks: 05)
___________________________________________________________
Consider the following graph and construct its Minimum Spanning Tree (MST) using Kruskal’s
algorithm.
Answer
Answer
Answer
Question No: 50 (Marks: 05)
___________________________________________________________
Generate the Huffman binary tree for the string baadebbc based on the following frequency table.
Character a b c d e
Frequenc 2 3 1 1 1
y
Answer