Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

COMSATS University Islamabad, Vehari Campus

Department of Computer Science


Final Examination – Fall 2020
Subject: Design & Analysis of Algorithms Instructor: Uzair Ishtiaq
Class: BCS-B17 Total Time: 180 Minutes
Maximum Marks: 50 (40 Final Exam + 10 Viva) Registration Number:___

NOTE: Answer the questions on white pages of A4 size. Only handwritten solution will be acceptable.
Every page must contain Name, Registration, Section and page number. Upload the solution in one
PDF file within the given time on CUOnline. Keep your cameras on during the exam.

Q – 1: In Philippines, coins of 1, 5, 10, 25 centavos (officially called sentimo), 1₱, 5₱ and 10₱
(officially called Peso) and currency notes of 20₱, 50₱, 100₱, 500₱, 1000₱ are used. How can
we make the following denominations using Coin Change Problem with greedy approach? Also
write an algorithm for coin change problem using dynamic programming with its complexity
analysis. [15]
i) 7.34 ₱
ii) 2891.45 ₱
iii) 390.21 ₱
iv) 74.58 ₱
v) 0.99 ₱

Q – 2: Consider the following graph: [10]

i) What will be the order of the nodes being traversed using Depth First Search?
ii) What will be the order of the nodes being traversed using Breadth First Search?
iii) If we implement the bag using a stack, show how will we push the nodes into the
stack using DFS?
iv) If we implement the bag using a stack, show how will we push the nodes into the
stack using BFS?

Q – 3: Write down the algorithm for Huffman Encoding Technique with its complexity analysis.
Consider your name and registration number as a string, apply Huffman Encoding Technique on
this string. (e.g. MUHAMMAD-ALI-MUSA-FA14-BCS-101) [15]

“Think before you speak. Read before you think.”


― Fran Lebowitz

You might also like