CS502 Sample Paper Solution by KST Learning
CS502 Sample Paper Solution by KST Learning
FINALTERM EXAMINATION
Solved By KST Learning (0347-2506073)
CS502 - Fundamentals of Algorithms
Time: 90 min
Marks: 60
a) Search Problem
b) Computational Problem
c) Optimization Problem Check Handouts
d) Parallel Computation Problem
a) Search Problem
b) Computational Problem
c) Optimization Problem Check Handouts
d) Parallel Computation Problem
a) Greedy algorithm
b) 2 D dynamic programming
c) 1 D dynamic programming Page # 95
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 Page # 91
c) 170
d) 90
Which of the following algorithms is the best approach for solving Huffman codes?
a) exhaustive search
b) greedy algorithm Page # 99
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 Page # 101
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?
You are given infinite coins of denominations v1, v2, v3,…..,vn and a sum S. The coin change problem
is to find the minimum number of coins required to get the sum S. This problem can be solved using
____________.
a) Greedy algorithm
b) Dynamic programming Page # 98
c) Divide and conquer
d) Backtracking
Question No: 13 (Marks: 01) - Please choose the correct option
You are given infinite coins of N denominations v1, v2, v3,…..,vn and a sum S. The coin change
problem is to find the minimum number of coins required to get the sum S. What is the time complexity
of a dynamic programming implementation used to solve the coin change problem?
a) O(N)
b) O(S)
c) O(N2)
d) O(S*N) Page # 99
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 Page # 109
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
The number of edges in a Minimum Spanning Tree (MST) is _____________ the number of edges in
the original graph.
a) Greater than
b) Less than or greater than
c) Subset of
d) Equal to Page # 143
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 Page # 143
Kruskal’s algorithm is used for computing Minimum Spanning Tree (MST) and is based on
____________ strategy.
a) Dynamic Programming
b) Greedy Check Internet
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 Page # 154
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 Page # 154
b) Floyd-Warshall Algorithm
c) Bellman Ford
d) Johnson
Floyd Warshall’s algorithm is used for computing shortest paths and is based on ____________
strategy.
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 Check Internet
d) Level-order traversal time stamp
Answer
((A1A2)A3) = (5 . 4 . 6) + (5 . 6 . 2) = 180
(A1(A2A3)) = (4 . 6 . 2) + (5 . 4 . 2) = 88
Write down at least three real life applications of Minimum Spanning Tree (MST).
___________________________________________________________
Answer
1) Telecommunication Network
2) Transportation Network
3) Power Grid
Question No: 43 (Marks: 03)
__________________________________________________________
Identify algorithms from the following list which compute the Minimum Spanning Tree (MST) in an
undirected Graph.
Dijkstra
Prim
Bellman Ford
Kruskal
Floyd Warshall
Answer
Answer
Answer
What is an adjacency matrix and how is it used to represent the connections between vertices in a graph?
Answer
Consider the following graph and construct its Minimum Spanning Tree (MST) using Kruskal’s
algorithm.
Answer
Answer
1) Designate the start location as the initial node and the destination location as the target node.
2) Begin by enqueueing the start node into the BFS queue and mark it as visited.
3) While the queue is not empty, dequeue a node and examine its neighbors.
4) For each unvisited neighbor, enqueue it into the queue, mark it as visited, and record its parent node.
5) Continue this process until the destination node is reached, at which point the shortest path has been found.
6) To reconstruct the shortest path, trace back from the destination node using the recorded parent nodes until the start
node is reached.
Answer
Character a b c d e
Frequency 2 3 1 1 1
Answer 8
0 1
5 3
0 1 0 1
d:1 e:1
KST Learning YouTube
Channel
Paid Services Available
Assignments
Quiz
GDBs
Projects
Online Classes
CS519 Projects
CS619 Projects
0347-2506073
Please Like, Share
Subscribe
KST Learning