You are on page 1of 3

Mid-Term Summer-2021

Department of Computer Science

Subject: Design and Analysis of Algorithms Submission Day: Tuesday


Instructor: Dr. Aarij Mahmood Hussaan Submission Date: 7th September 2021
Program: BS(CS) / BS(SE) Max. Marks: 40

Please follow the instructions carefully:

1. Write your answers directly on the Black Board (recommended) or upload word file before
the due date on Blackboard.
2. Write your name and registration ID on the first page of your Word file.
3. Answer scripts can only be uploaded on Blackboard only during the submission time.
4. To avoid any unforeseen problems, you are advised to follow the Guide lines communicated
by the Faculty Members.
5. Submission of answer copy(ies) will be considered acceptable through Blackboard only.
Therefore, do not submit your document through email or any other medium.
6. Use 12 pt. font size and Times New Roman font style along with 1-inch page margins.
7. Follow the requirements of the word limit and the marking criteria while writing your
answers.
8. Provide relevant, original and conceptual answers, as this exam aims to test your ability to
examine, explain, modify or develop concepts discussed in class.
9. Do not copy answers from the internet or other sources. The plagiarism of your answers may
be checked through Turnitin.
10. Double check your word file before uploading it on BlackBoard to ensure that you have
uploaded the correct file with your answers.

This study source was downloaded by 100000867677487 from CourseHero.com on 06-07-2023 12:06:30 GMT -05:00

https://www.coursehero.com/file/105277405/Final-DNA-SUMMER-2021pdf/
Q1 (a) Consider a optimal solution characterization of an algorithm in following equation. 4
Convert this equation into a recursive algorithm.
 V [k − 1, w] if wk  w
V [k , w] = 
max{V [k − 1, w],V [k − 1, w − wk ] + bk } else
(b) Create the optimal binary search tree for the following items, where the probability 6
occurrence of each word is given in parentheses: FOR(.05), WHILE(.1), return(.02),
static(.02), void(.06), class(.07), public(,04), static(.08), void(.03), float(.09), int(.01),
double(.08), String(.04), CASE (.05), ELSE (.06), END (.05), IF (.05), OF (.07), THEN
(.03).
Q2 (a) Can we use a greedy approach to solve the sorting problem? Explain your answer. 2
(b) Apply Kruskal’s algorithm to find the MST of the following graph. (Show all steps) 3

Q3 (a) Why is it a guarantee that Bellman-Ford Algorithm will always return false whenever 3
there is a cycle ‘c’ in the graph, where the weight of the cycle is less than zero.
(b) Execute Dijkstra’s algorithm on the following graph. Start with A. 5

This study source was downloaded by 100000867677487 from CourseHero.com on 06-07-2023 12:06:30 GMT -05:00

https://www.coursehero.com/file/105277405/Final-DNA-SUMMER-2021pdf/
Q4 (a) Is there a greedy algorithm to solve the Max-Flow problem? If there is write its pseudo- 2
code? If there isn’t show why not.
(b) Find the maximum flow of the following graph. Show all the steps 6

Q5 (a) Find the connected components of the following graph: 4

(b) Run BFS on the following graph, show all steps, Also show the d and pi value of each 3
vertex. Start from V1

**************** Good Luck *********************

This study source was downloaded by 100000867677487 from CourseHero.com on 06-07-2023 12:06:30 GMT -05:00

https://www.coursehero.com/file/105277405/Final-DNA-SUMMER-2021pdf/
Powered by TCPDF (www.tcpdf.org)

You might also like