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

Tutorial 7

Uploaded by

Sara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
4 views1 page

Tutorial 7

Uploaded by

Sara
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 1

[CSN212] Study Group 7

Dynamic Programming 2

1 Number of parenthesis
Count the number of expressions containing n pairs of parentheses that are correctly matched. For n = 3,
possible expressions are ((())), ()(()), ()()(), (())(), (()()).
Note: The above number is also called Catalan number which can be computed faster, but think of DP
approach to count number of possibilities.

2 Maximum Independent Set in Tree.


Given a tree T = (V, E), design and analyze an algorithm to find a maximum size subset I ⊆ V such that
for all u, v ∈ I it holds (u, v) ∈
/ E. This is called the Maximum independent set problem, which is NP-hard
for general graphs. Hint. Two possible states of every node v are being in V ′ and not being in V ′ .

3 Longest Increasing Subsequence Variant.


Given an array A[n], we have studied an algorithm to report the length of its longest increasing subsequence.
Design and analyze (time and space) an O(n2 k) algorithm to compute the length of the longest increasing
subsequence that consists of at most k contiguous subarrays. Eg. A = {1, 3, 5, 2, 6, 7, 2, 4, 9, 12, 15}, and
k = 3, the optimal solution is [1, 3, 5], [6, 7], [9, 12, 15]. With k = 2 the optimal solution is [1, 3, 5], [9, 12, 15].

4 Bitonic shortest path in DAG.


Given a directed acyclic graph G = (V, E) having positive edge weights, a bitonic path has subsequent edge
weights first strictly increasing up to some vertex and then strictly decreasing (strictly implies adjacent edges
cannot have equal weights). Design and analyze an algorithm to compute the shortest bitonic paths from a
given source s to all vertices.

5 Programming
Solve and submit on codechef by end of the week.
• https://www.codechef.com/SEP12/problems-old/CROWD
• https://www.codechef.com/problems/CR195

You might also like