Algo Midterm
Algo Midterm
Name:_____________________________ ID:______________________________
Instructions:
• Do Not Start the Paper until asked to do so.
• Attempt all Questions.
• Understanding the question paper is also part of the exam. Make suitable ASSUMPTIONS.
• Solve all the questions on the provided answer sheet.
• Be sure to read questions carefully and answer all parts. Use complete sentences and explain your
answers.
• Use of mobile phones or any other electronic device/gadget is strictly prohibited. If any student is
found using a mobile phone during the examination, this would be considered a case of academic
misconduct and treated as a UMC offence. Cell Phones should be turned off.
• Leave your books/notes or any kind of helping material at the front of the examination room.
• Any kind of cheat sheet if found will result in immediate disqualification from the Exam and F as
the final grade in your course.
Q.no1 (CLO1)= 5 Q.no.2 (CLO1)= 5 Q.no.3(CLO2) =10 Q.no.4 (CLO2)= 5 Total =25
1
Question 01: [CLO 1] 3+2=5
i. Analyze the worst-case Time Complexity of the following piece of code by any
means that you have studied.
void myFunction(int n)
{
for (int i = 0; i < n; ++i) {
cout << i << " "; }
int main() {
int n = 10;
if (i < 0) {
myFunction(i);
} return 0; }
2
Question 02: [CLO1] 2.5x2=5
i. What are asymptotic notations. Write some of their properties.
ii. Write all the scenarios when the recurrence equation cannot be solved using the
master theorem.
3
Question 03: [CLO2] 5+5=10
Compute the Worst time complexity of the following using Master Theorem.
i. T(n)= 9T(n/3) +n2
4
ii. T(n)= 4T(n/2)+ n/(logn)2
5
Question 04: [CLO2] 5
Solve by Recursion tree method to find Big O.