0% found this document useful (0 votes)
74 views1 page

Analysis of Algorithms: Dec 07, 2020, Before 8.00pm

The document provides instructions for submitting a quiz on analysis of algorithms and includes 3 questions. Question 1 asks for a dynamic programming algorithm to find the longest palindrome subsequence in a string. Question 2 describes an assembly line problem with 2 lines and n stations, and asks for a dynamic programming solution to find the fastest way to assemble a product. Question 3 asks to solve the 0-1 knapsack problem given item weights and values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views1 page

Analysis of Algorithms: Dec 07, 2020, Before 8.00pm

The document provides instructions for submitting a quiz on analysis of algorithms and includes 3 questions. Question 1 asks for a dynamic programming algorithm to find the longest palindrome subsequence in a string. Question 2 describes an assembly line problem with 2 lines and n stations, and asks for a dynamic programming solution to find the fastest way to assemble a product. Question 3 asks to solve the 0-1 knapsack problem given item weights and values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Analysis of Algorithms Total Marks: 30

Quiz 04
Submission Details:
 Submit the zip folder of your solution via mail at [email protected],
On Dec 07, 2020, Before 8.00pm
 The email subject should be BCSF18(M or A)/BSEF18(M or A)_Quiz 4
 Late submissions are not allowed.

Q. 1: A palindrome is a nonempty string over some alphabet that reads the same forward and
backward. Examples of palindromes are all strings of length 1, civic, racecar, and aibohphobia
(fear of palindromes).
Give an efficient dynamic programming algorithm to find the longest palindrome that is a
subsequence of a given input string. For example, given the input character, your algorithm
should return carac. What is the running time of your algorithm?

Q. 2: Consider the following situation:


• There are two assembly lines, each with n stations, for manufacturing some product.
• The time required at station i is not necessarily the same in both assembly lines
• There is a time cost to switching between assembly lines.
In the following example, there are three stations on each line, the time to get from the entry to
line 1 is e1, the time to do station 1 on line 1 is a11, etc., the time to transfer from line 1 to line 2
between stations 1 and 2 is t11, etc., and the time to get from station 3 to the exit is x2. Similarly
for line 2.

Question: What is the fastest way to assemble the product (to get from the entry to the exit)? In
a brute force approach, we could consider all possibilities (e.g., use station i on line j, for i = 1, . .
. , n and j = 1, 2). But there are 2𝑛 possible solutions, so this is not feasible. Give the dynamic
programming solution.

Q.3: Solve the 0-1 knapsack problem for following input:

Knapsack Capacity: 11
Item 1 2 3 4 5
Weight 1 2 5 6 7
Value 1 6 18 22 28

You might also like