Analysis of Algorithms: Dec 07, 2020, Before 8.00pm
Analysis of Algorithms: Dec 07, 2020, Before 8.00pm
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?
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.
Knapsack Capacity: 11
Item 1 2 3 4 5
Weight 1 2 5 6 7
Value 1 6 18 22 28