You are on page 1of 2

Barani Institute of Management Sciences

Mid-Term Exam Spring Semester 2021


Course Title : Analysis of Algorithms Course Code : CS - 542

Discipline /Program : BSCS Total Marks : 18


Time allowed : 12 Hours Instructor’s Name(s): Saira Sultana

Believe you can, Don’t stress, Do your best.

Question No 1: Compute the following sums. (1+1)

1. 2+ 5 + 8+ 11+ …….. + 59 i(6i+2i)


2.
Question No 2: What is being done in following algorithm can we perform better if yes then
how if no then why? (2+2)

Question No 3: Why we use asymptotic notation? List the following function according to
their order of growth from the lowest to highest. (2)

6(n^2)/6n, (6nn – 7/3), 100n log2 n, (n3+50), (3/2 + 4 – 8/2), (2n2+3), 25n
Question No 4: suppose we have two algorithms (A and B) for a single problem where A’s
time complexity is n! and B’s is 1. Assume two different data set of n sizes ,consider( n=10
and n=50) for each algorithm. Which one will be preferable and why ,justify your answer?

(2)

Question No 5: Prove that these statements true or false? (4)

Statement T (or) F Prove


2
½ (100n + 5n/5+ 20 )≠
O(n3)
n(n2 + 1)/2 ≠ Θ(n)
n(n3 + 1)/2 ∈ O(1)
n(n + 1)/2 ≠ Ω (1)
7n + 3nlogn+ n ∈ Θ(n2)

Question No 6: analyze the following find algorithm, identify primitive operations on each
step also calculate its complexity function . (2+2)
UniqueElements(A[0..n-1])

for(i= 0; i<n; i++)

for(j = 0; j<n; j++)

if(A[i] = A[j])

return false

for(int j = i; j < N; j++)

sum = 0;

Max_sum= A[N-1];

for(int k = i; k <= j; k++)

sum = sum + A[k];

if(sum > Max_sum)

Max_sum = sum;

You might also like