0% found this document useful (0 votes)
24 views14 pages

CS502 Sample Paper Solution by KST Learning

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)
24 views14 pages

CS502 Sample Paper Solution by KST Learning

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/ 14

Sample Paper

FINALTERM EXAMINATION
Solved By KST Learning (0347-2506073)
CS502 - Fundamentals of Algorithms

Time: 90 min
Marks: 60

Question No: 1 (Marks: 01) - Please choose the correct option

Matrix chain multiplication is a/an___________ type of problem.

a) Search Problem
b) Computational Problem
c) Optimization Problem Check Handouts
d) Parallel Computation Problem

Question No: 2 (Marks: 01) - Please choose the correct option

Dynamic Programming Algorithms involves solving the problem by________.

a) Breaking up into sub-problems Page # 85


b) Only One Individual problem
c) One Part of problem
d) Starting from the first part of problem

Question No: 3 (Marks: 01) - Please choose the correct option

Matrix chain multiplication is a/an___________ type of problem.

a) Search Problem
b) Computational Problem
c) Optimization Problem Check Handouts
d) Parallel Computation Problem

Question No: 4 (Marks: 01) - Please choose the correct option

The Knapsack problem is an example of ____________.

a) Greedy algorithm
b) 2 D dynamic programming
c) 1 D dynamic programming Page # 95
d) Divide and conquer

Question No: 5 (Marks: 01) - Please choose the correct option

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

Question No: 6 (Marks: 01) - Please choose the correct option

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

Question No: 7 (Marks: 01) - Please choose the correct option

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?

a) Divide and conquer


b) Dynamic programming
c) Greedy algorithm Page # 109
d) Backtracking

Question No: 9 (Marks: 01) - Please choose the correct option

The main time taking step in fractional knapsack problem is ___________.

a) Breaking items into fraction


b) Adding items into knapsack
c) Sorting Check Internet
d) Looping through sorted items

Question No: 10 (Marks: 01) - Please choose the correct option

Which bit is reserved as a parity bit in an ASCII set?


a) first
b) seventh
c) eighth Check Internet
d) tenth

Question No: 11 (Marks: 01) - Please choose the correct option

What does the Activity Selection Problem mean__________?

A) Scheduling Problem Page # 105


B) Search Problem
C) Computational Problem
D) Non Computational Problem

Question No: 12 (Marks: 01) - Please choose the correct option

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

Question No: 14 (Marks: 01) - Please choose the correct option

What is the fractional knapsack problem?


a) A problem in computer science that deals with sorting algorithms
b) A problem in mathematics that deals with dividing a line segment into a given number of equal
parts
c) A problem in optimization that deals with selecting items to include in a knapsack so as to
maximize the total value of items in the knapsack Page # 109
d) A problem in physics that deals with calculating the force exerted by a gas on a container

Question No: 15 (Marks: 01) - Please choose the correct option

What is the objective of the fractional knapsack problem?


a) To find the minimum weight of items that can be selected to fill the knapsack
b) To find the maximum weight of items that can be selected to fill the knapsack
c) To find the minimum value of items that can be selected to fill the knapsack
d) To find the maximum value of items that can be selected to fill the knapsack Page # 109

Question No: 16 (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 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

Question No: 17 (Marks: 01) - Please choose the correct option

A free tree does not have _______________ node/vertex.


a) Root Page # 142
b) Left child
c) Right child
d) Leaf

Question No: 18 (Marks: 01) - Please choose the correct option

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

Question No: 19 (Marks: 01) - Please choose the correct option

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

Question No: 20 (Marks: 01) - Please choose the correct option

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

Question No: 21 (Marks: 01) - Please choose the correct option

The Time complexity of Prim’s algorithm is ________________.


a) Θ (logE + logV)
b) Θ (log E V)
c) Θ (E log V) Page # 153
d) Θ (log E+V)

Question No: 22 (Marks: 01) - Please choose the correct option

Dijkstra’s algorithm is used to compute ___________________ in a directed graph.


a) Single-source shortest paths Page # 154
b) Single destination shortest paths
c) Single-pair shortest paths
d) All-pairs shortest paths

Question No: 23 (Marks: 01) - Please choose the correct option


The Dijkstra algorithm maintains estimate of the shortest path from source vertex to ____________
a) Destination vertex
b) Neighbor vertex
c) Neighbor of the neighbor vertex
d) All vertices in the graph Page # 154

Question No: 24 (Marks: 01) - Please choose the correct option

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

Question No: 25 (Marks: 01) - Please choose the correct option

If a shortest paths algorithm allow negative cost cycle, then the algorithm will compute

a) Multiple paths between pair of vertices Check Internet


b) Only one Path between pair of vertices
c) Incorrect path between pair of vertices
d) No Path between pair of vertices

Question No: 26 (Marks: 01) - Please choose the correct option

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

Question No: 27 (Marks: 01) - Please choose the correct option

The Time complexity of Bellman-Ford’ algorithm is ________________.


a) Θ (logE + logV)
b) Θ (log E V)
c) Θ (E V) Page # 159
d) Θ (E+V)
Question No: 28 (Marks: 01) - Please choose the correct option

Floyd Warshall algorithm is used to compute _________________________ in a graph.


a) Single-source shortest paths
b) Single destination shortest paths
c) Single-pair shortest paths
d) All-pairs shortest paths Page # 161

Question No: 29 (Marks: 01) - Please choose the correct option


Which one among the following is the slowest algorithm for computing shortest paths?
a) Dijkstra’s algorithm
b) Floyd-Warshall Algorithm Page # 161
c) Bellman Ford
d) Prims

Question No: 30 (Marks: 01) - Please choose the correct option

Floyd Warshall’s algorithm is used for computing shortest paths and is based on ____________
strategy.

a) Dynamic Programming Page # 161


b) Greedy
c) Divide and Conquer
d) Backtracking

Question No: 31 (Marks: 01) - Please choose the correct option

Which bit is reserved as a parity bit in an ASCII set?


a) first
b) seventh
c) eighth Check Internet
d) tenth

Question No: 32 (Marks: 01) - Please choose the correct option

What is an adjacency list?


a) A list of nodes and their edges in a graph Page # 116
b) A list of nodes in a graph, without any edges
c) A list of edges in a graph, without any nodes
d) A list of nodes in a graph, with their edges represented as a matrix

Question No: 33 (Marks: 01) - Please choose the correct option


What is an adjacency matrix used for in graph theory?
a) To represent the distances between nodes
b) To represent the edges between nodes Page # 116
c) To represent the weights of nodes
d) To represent the orientation of nodes

Question No: 34 (Marks: 01) - Please choose the correct option

Which of the following best describes Breadth First Search (BFS)?


a) BFS is a search algorithm that starts at the root node and visits all the nodes along the shortest
path first, before visiting the more distant nodes.
b) BFS is a search algorithm that visits all the nodes at the same depth before moving on to the next
level. Check Internet
c) BFS is a search algorithm that visits nodes in a random order.
d) BFS is a search algorithm that visits all the nodes in the order they were added to the tree.

Question No: 35 (Marks: 01) - Please choose the correct option

Which of the following best describes Depth First Search (DFS)?


a) DFS is a search algorithm that starts at the root node and visits all the nodes along the shortest
path first, before visiting the more distant nodes.
b) DFS is a search algorithm that visits all the nodes at the same depth before moving on to the next
level.
c) DFS is a search algorithm that visits nodes in a random order.
d) DFS is a search algorithm that visits all the nodes by exploring as far as possible along each
branch before backtracking. Check Internet

Question No: 36 (Marks: 01) - Please choose the correct option

What is the characteristic feature of Breadth First Search (BFS)?


a) Visits all nodes along the shortest path first
b) Visits all nodes at the same depth before moving to the next level Check Internet
c) Visits nodes in a random order
d) Visits all the nodes in the order they were added to the tree

Question No: 37 (Marks: 01) - Please choose the correct option

What is a Directed Acyclic Graph (DAG)?


a) A graph with directed edges and cycles
b) A graph with directed edges and no cycles Page # 116
c) A graph with undirected edges and cycles
d) A graph with undirected edges and no cycles

Question No: 38 (Marks: 01) - Please choose the correct option

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

Question No: 39 (Marks: 01) - Please choose the correct option

What is the characteristic feature of Depth First Search (DFS)?


a) Visits all nodes along the shortest path first
b) Visits all nodes at the same depth before moving to the next level
c) Visits nodes in a random order
d) Visits all the nodes by exploring as far as possible along each branch before backtracking

Question No: 40 (Marks: 01) - Please choose the correct option


What is the main property of a Directed Acyclic Graph (DAG)?
a) The edges are undirected
b) There are cycles present in the graph
c) The edges are directed and there are no cycles present in the graph Page # 116
d) There is a unique path between any two vertices in the graph

Question No: 41 (Marks: 03)

Consider the case of 3 matrices: A1 is 5 × 4, A2 is 4 × 6 and A3 is 6 × 2 The multiplication can be carried


out either as ((A1A2)A3) or (A1(A2A3)). Calculate the cost of these two matrices.

Answer
((A1A2)A3) = (5 . 4 . 6) + (5 . 6 . 2) = 180
(A1(A2A3)) = (4 . 6 . 2) + (5 . 4 . 2) = 88

Question No: 42 (Marks: 03)

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

Question No: 44 (Marks: 03)


___________________________________________________________
What makes Directed Acyclic Graphs (DAGs) a useful data structure for representing hierarchical
relationships and relationships between events?

Answer

Question No: 45 (Marks: 03)


___________________________________________________________
How does the fractional Knapsack algorithm differ from the 0/1 Knapsack algorithm, and how can it be
used to solve problems with continuous or fractional values.

Answer

Question No: 46 (Marks: 03)


___________________________________________________________

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

Question No: 48 (Marks: 05)


___________________________________________________________
Suppose you are given a map of a city with different locations and roads connecting them. How would
you use the Breadth-First Search (BFS) algorithm to find the shortest route between two specific
locations in the city?

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.

Question No: 49 (Marks: 05)


___________________________________________________________
What is the time stamp structure used in Depth-First Search (DFS) algorithm, and how does it help in
identifying different types of edges in a graph, such as tree edges, back edges, forward edges, and cross
edges?

Answer

Solution on Page # 128

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
Frequency 2 3 1 1 1

Answer 8
0 1

5 3
0 1 0 1

a:2 b:3 c:1 2


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

You might also like