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

Daffodil International University

Department of Software Engineering


Faculty of Science & Information Technology
Midterm Exam Examination, Fall 2020 @ DIU Blended Learning Center
Course Code:SE214-MC, Course Title: Algorithms Analysis and Design
Level: 2 Term: 1 Section: A
Instructor: MAH Modality: Open Book Exam
Date: Sunday, 8 November, 2020 Time: 02:15 PM - 04:45 PM Marks: 25
----------------------------------------------------------------------------------------------------------------------------
1. Consider the following two algorithms for determining whether anyone in the
classroom has the same birthday as you. ​[do not need to write C code, just explain]
Algorithm 1: You say your birthday, and ask whether anyone in the room has the
same birthday. If anyone does have the same birthday, they answer yes.
Algorithm 2: You tell the first person your birthday, and ask if they have the same
birthday; if they say no, you tell the second person your birthday and ask whether
they have the same birthday; etc, for each person in the room.
a) For each algorithm, what is the factor that can affect the number of questions
asked (the "problem size")?
2
b) In the worst case, how many questions will be asked for each of the three
algorithms?
2
c) For each algorithm, say whether it is constant, linear, or quadratic in the
problem size in the worst case. 2

2. Write ​C code to find the first 7 Fibonacci numbers using recursion. Also print, how 4
many times the Fibonacci function called for the 3rd Fibonacci number (3rd fib is 2)
during a recursive call. Compare the dynamic programming approach and recursive
solution to find out Fibonacci series.

3. In the pandemic situation, you are staying at home. Your brother is asking about 5
academic progress and becomes happy hearing that you are doing good in the
algorithm course. So, he wants to test your skill in this course.
He asked you to find out the matches Letters between ​your name ​and your ​father's
name​. Then, he told you to find out the process by which you can find the Longest
matching subsequence.
Now, your task is to examine and analyze the above story, then determine the
appropriate procedure and show every step to find out the longest matching
subsequence to find out matches letters.
4. Dhaka Stock Exchange (DSI) is the largest stock exchange in Bangladesh.
Thousands of people are investing their capital. In the last week, 7 billions of BDT
has exchanged in the first day, 6 billions in the second day, 8 billions in the next day,
5 billions in the next day and 7 billions in the last day of the week.
Investors should be aware of the up and down of the market. So your task is to write
a procedure that will find out the low point(s) of the week. ​Low point refers to the
value that is lower compared to his previous and next value. ​Here 6 and 5 are the
low values.
Analyze the above story and determine the procedure which will be able to work in 4
any given week data. Write corresponding ​C code and also mention the complexity +
of your code. 2
Sample input: 7 6 8 5 7 Output: 6 5
Sample input: 5 6 1 3 2 Output: 5 1 2

5. What do you mean by dynamic algorithms approach? Define the following terms 4
with proper explanation and examples:
● Overlapping subproblems
● Optimal substructure
● Subproblem Dependencies
● Memorization

You might also like