Вы находитесь на странице: 1из 2

Bahria University Total Pages: 2

Lahore Campus
Mid Term Assessment (Spring-2020 Semester)
Department of Computer Sciences

Date & Time: 13th May, 2020

Due Date: 22nd May, 2020

Instructor Name: Muhammad Arif Program/Semester: BS(CS)-5(A)


Course Code: CSC-321 Course Title: Design and Analysis of Algorithm
Max Marks: 20 Weightage: 20%

Instructions:
Read out the Instructions carefully.
I. Attempt all questions
II. The questions include a marking scheme and this is particularly important for questions requiring
descriptive answers. The number of marks should guide the length of the answer.
III. If you cannot understand a solution for a question, or suspect that it is wrong, spend an hour or so to
attempt to fully understand it. Then, if you are still uncertain, leave it for a day or two and come back to
it with a fresh mind.
IV. Do not copy from internet or slides or book, use your own words. The plagiarism report will be generated
for each mid-term exam and if any material found copied from internet or similar to other students mid-
term then he/she will be marked as zero. Write in your own words.
V. Write every step wherever required, do not use short cuts.

OBJECTIVES:

No. Detail Problem No.


CLO1 Argue the correctness of algorithms using inductive proofs and invariant. Problem No.1
Problem No.2
CLO2 Analyze worst-case running times of algorithms using asymptotic analysis Problem No.1
CLO3 Describe the divide-and-conquer paradigm and explain when an algorithmic
design situation calls for it. Recite algorithms that employ this paradigm. Problem No.1
Synthesize divide-and-conquer algorithms. Derive and solve recurrences
describing the performance of divide-and-conquer algorithms.
CLO4 Describe the dynamic-programming paradigm and explain when an algorithmic
design situation calls for it. Recite algorithms that employ this paradigm. Problem No.2
Synthesize dynamic-programming algorithms, and analyze them.

1
Problem 1: Find the Longest Common Prefix (LCP) between given set of strings. [08 Marks]

Write an efficient algorithm by using divide and conquer technique to find the longest Common Prefix
(LCP) between given set of strings.

For Example:
Input: technique, technician, technology, technical
Output: The longest common prefix is “techn”

Calculate the runtime of algorithm and represent in theta/ Oh/ Omega notation.

Problem 2: Blueberries Problem


Problem Description:
Teresa wants to pick up the blueberries in such a way that she may not exceed the limit proposed.
When picking the blueberries, she noticed that if she picks from the bush i, she couldn’t pick the
blueberries at the bush i+1 (some sort of magic in rainbow land).
Worried about this, Teresa wants to know the maximum blueberries she can pick, given the number of
bushes and the number of blueberries in each bush.
Will contain an integer T, then, T cases will follow, each case starts with a number N and K, being N the
number of bushes and K the number of blueberries Teresa will pick as maximum, the next line contains
N integers, each one representing the blueberries there is on the i-th bush.
Expected Input and Output
Case-1:
number of bushes=5
limit=100
Blueberries in each bush=50 10 20 30 40
Expected Result=90
Case-2:
number of bushes=5
limit=87
Blueberries in each bush=21 45 30 12 14
Expected Result=65
Case-3:
number of bushes=4
limit=42
Blueberries in each bush=13 28 25 15
Expected Result=38
Requirements:
1- Design the solution of problem by using Dynamic Programming approach.
2- Write algorithm/ code of solution. [12 Marks]

***************************The End***************************
2

Вам также может понравиться