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

CS214 Exam 2019

Uploaded by

jashwinsinghfj11
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)
22 views14 pages

CS214 Exam 2019

Uploaded by

jashwinsinghfj11
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

CS214: Design & Analysis of Algorithms

SCIMS, FSTE

Final Examination
Semester II, 2019

F2F/Blended Mode

Duration of Exam: 3 hours + 10 minutes

Reading Time: 10 minutes

Writing Time: 3 hours

Total Marks: 40

Instructions:

1. Write your answers in the space provided in this Question Paper.


2. Answer all questions. There are 12 questions and all questions are
compulsory.
3. This exam is worth 40% of your overall mark. The minimum mark to pass the
final exam is 16/40.
4. Total number of pages including this cover sheet is 14.
5. This is a closed book exam. No printed materials and electronic devices are
allowed.

ID:___________________________ Name:_____________________________

SeatNo: _______________________
ID: ______________________

8. For the given phrase “tuition at institution”, find its corresponding encoded value using
Huffman’s algorithm and calculate the ratio of compression achieved. (4 Marks)
Note: Each character in a phrase occupies 1 byte of memory and ignore the blanks in the given
phrase.

Page 9
ID: ______________________

9. (a) Write a pseudo code to disperse change from vending machine using greedy approach
(2 Marks)

(b) Apply Greedy approach to give a change of 78c from available coins 54c, 44c, 34c, 14c, 4c, 2c.
Justify whether you have got locally optimal or globally optimal solution. (1 Mark)

Page 10
ID: ______________________

10. (a) Find the minimum cost spanning tree for the given graph using prim’s and kruskal’s
algorithm. Show the output after every stage while using these algorithms (4 Marks)

Page 11
ID: ______________________

(b) Which is the better of two algorithms for the above graph? Explain your answer. (1 Mark)

11. Use the single source shortest path algorithm to obtain in nondecreasing order the lengths of
the shortest paths from vertex 1 to all the remaining vertices in the digraph given below.
(2 Marks)

Page 12
ID: ______________________

12. Consider the 0-1 Knapsack problem with four different items having different weights and
profit values:
Item 1 (2 kg, $3)
Item 2 (3kg, $5)
Item 3 (4kg, $6)
Item 4 (5kg, $10)
The knapsack has a capacity of 8kg

(a) Use the greedy approach to compute the optimal profit in filling the knapsack ( 1 Mark)

(b) Use the backtracking algorithm for the above 0-1 knapsack problem to maximize the profit and
show the state space tree (4 Marks)

Page 13
ID: ______________________

(c) Which is the better of two approaches above? Explain your answer. (1 Mark)

Page 14

You might also like