0% found this document useful (0 votes)
8 views4 pages

Algo Lab - DP

The document outlines several algorithmic problems including the Fibonacci number, coin change problem, rod cutting, 0-1 knapsack, subset sum problem, and longest common subsequence. It provides examples and hints for solving the subset sum problem and the longest common subsequence problem. The document emphasizes the relationship between these problems and dynamic programming techniques.

Uploaded by

imranahmed201320
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)
8 views4 pages

Algo Lab - DP

The document outlines several algorithmic problems including the Fibonacci number, coin change problem, rod cutting, 0-1 knapsack, subset sum problem, and longest common subsequence. It provides examples and hints for solving the subset sum problem and the longest common subsequence problem. The document emphasizes the relationship between these problems and dynamic programming techniques.

Uploaded by

imranahmed201320
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/ 4

Fibonacci number

Coin change problem


Rod cutting

0-1 Knapsack
Subset sum problem
You are given an array A and a number N. You need to find out if N is a sum of any subset of A or not.

Example:

A = {2, 4, 5, 6, 8}, N = 15 → True {4, 5, 6}

A = {2, 4, 5, 6, 8}, N = 0 → True {}

A = {2, 4, 5, 6, 8}, N = 3 → False

Hint: similar to 0-1 knapsack. Think of A as set of items, N as knapsack capacity.

Longest common subsequence

Given two strings x and y, find the longest common subsequence and its length.

Example:

x = “ABCBDAB”

y = “BDCABA”

longest common subsequence = “BCBA”

longest common subsequence length = 4

x = “ABBACQ”

y = “XAYZMBNNALQCTRQ”

longest common subsequence = “ABACQ”

longest common subsequence length = 5

Hint: CLRS 15.4

You might also like