SlideShare a Scribd company logo
POSCAT Seminar 7 :
Dynamic Programming 1
yougatup @ POSCAT
1
Topic
 Topic today
− Dynamic Programming
• Basic Concept
• Longest Increasing Subsequence
• Longest Common Subsequence
POSCAT Seminar 1-2
9 July 2014
yougatup
Dynamic Programming
 Problem Solving Paradigm
− Identifying a collection of subproblems
− Tackling them one by one
• smallest first
• using the answer already calculated to help figure out the
larger ones
• until the whole problem is solved
 One of the most prominent issue
− You can be familiar with PS with Dynamic Programming
− There are so many issues to cover
POSCAT Seminar 1-3
9 July 2014
yougatup
Dynamic Programming
 Procedure
1. Define the Table
2. Find recurrence relation
3. Calculate !
POSCAT Seminar 1-4
9 July 2014
yougatup
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
POSCAT Seminar 1-5
9 July 2014
yougatup
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
POSCAT Seminar 1-6
9 July 2014
yougatup
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
POSCAT Seminar 1-7
9 July 2014
yougatup
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
Let 𝑇(𝑖) = The length of LIS when 𝑎𝑖 is the last element
∴ 𝑎𝑖 have to be last element of subsequence
POSCAT Seminar 1-8
9 July 2014
yougatup
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
You can fill the table manually. What is the answer ?
POSCAT Seminar 1-9
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
Can you see the recurrence relation on 𝑇 ?
POSCAT Seminar 1-10
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
Suppose that 𝑗 < 𝑖 and 𝐷𝑎𝑡𝑎 𝑗 < 𝐷𝑎𝑡𝑎(𝑖).
Then we can add one more element to Increasing Subsequence
whose last element is 𝐷𝑎𝑡𝑎(𝑗)
POSCAT Seminar 1-11
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
Consider element 6 in the example.
POSCAT Seminar 1-12
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
We can make a Increasing Subsequence by adding 6 whose last
element is 5. ∴ we can make “5 6”
POSCAT Seminar 1-13
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
However, we can make another Increasing Subsequence by
considering 2 ! Still the length is 2
POSCAT Seminar 1-14
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
We can’t make IS with 8 because 8 > 6
POSCAT Seminar 1-15
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
We can’t
POSCAT Seminar 1-16
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
1. Define the Table
We can make ! Therefore, our length is 3.
Note that we considered all the case.
POSCAT Seminar 1-17
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
2. Find a recurrence relation
𝑇 𝑖 = max 𝑇 𝑗 + 1 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑗 < 𝑖 & 𝐷𝑎𝑡𝑎 𝑗 < 𝐷𝑎𝑡𝑎(𝑖)
POSCAT Seminar 1-18
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
3. Calculate !
You have to think about where the answer is
POSCAT Seminar 1-19
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
3. Calculate !
You have to think about where the answer is
It must be the maximum value of whole Table
POSCAT Seminar 1-20
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Well, we can calculate the length of LIS.
Can we find subsequence itself? i.e. “2 3 6 9” in the example.
POSCAT Seminar 1-21
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Well, we can calculate the length of LIS.
Can we find subsequence itself? i.e. “2 3 6 9” in the example.
That’s possible by writing history !
POSCAT Seminar 1-22
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
What is the answer on this example ?
POSCAT Seminar 1-23
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
What is the answer on this example ?
POSCAT Seminar 1-24
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
What is the answer on this example ?
Then the last element of LIS must be 9 because the definition of 𝑇(𝑖)
said that 𝑎𝑖 should be the last element !
POSCAT Seminar 1-25
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Well, 9 is definitely last element of LIS.
How about other elements on LIS ?
POSCAT Seminar 1-26
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Well, 9 is definitely last element of LIS.
How about other elements on LIS ?
𝑇(6) is 4 because we add 9 to the end of IS whose last element is 6
POSCAT Seminar 1-27
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Therefore, 6 have to be located on the left of 9
POSCAT Seminar 1-28
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Therefore, 6 have to be located on the left of 9
Repeat this procedure until we have no former element
POSCAT Seminar 1-29
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Therefore, 6 have to be located on the left of 9
Repeat this procedure until we have no former element
POSCAT Seminar 1-30
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
It has no former element !
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
We call this procedure as “Backtrace”
To implement Backtrace, we have to write down the history.
POSCAT Seminar 1-31
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Hist. None None 1 1 1 4 5 5
It means that former element of 𝑎5 is 𝑎4 !
Longest Increasing Subsequence
 Problem
Find an increasing subsequence of greatest length
5 2 8 6 3 6 9 7
Implement it . It is very easy to make a stress of yours
POSCAT Seminar 1-32
9 July 2014
yougatup
index 0 1 2 3 4 5 6 7
Data 5 2 8 6 3 6 9 7
Table 1 1 2 2 2 3 4 4
Hist. None None 1 1 1 4 5 5
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
POSCAT Seminar 1-33
9 July 2014
yougatup
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
POSCAT Seminar 1-34
9 July 2014
yougatup
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
1. Define the Table
Give me !
POSCAT Seminar 1-35
9 July 2014
yougatup
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
1. Define the Table
Let 𝑇(𝑖, 𝑗) = The length of LCS between (𝑎1~ 𝑎𝑖) and (𝑏1~ 𝑏𝑗)
POSCAT Seminar 1-36
9 July 2014
yougatup
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
1. Define the Table Fill it manually !
POSCAT Seminar 1-37
9 July 2014
yougatup
S N O W Y
S
U
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
1. Define the Table How can we feel it ?
POSCAT Seminar 1-38
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
Consider this situation.
POSCAT Seminar 1-39
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
First of all, we can’t “match” O and U because they are different
POSCAT Seminar 1-40
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
Therefore, we can remove one or both element
POSCAT Seminar 1-41
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
What is the length of LCS when we remove O ?
POSCAT Seminar 1-42
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
What is the length of LCS when we remove O ?
POSCAT Seminar 1-43
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
It knows !
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
What is the length of LCS when we remove U ?
POSCAT Seminar 1-44
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
What is the length of LCS when we remove U ?
POSCAT Seminar 1-45
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1
N
N
Y
It has !
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
Therefore, the value of this entry is 1
POSCAT Seminar 1-46
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1 1
N
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
How about this situation ?
POSCAT Seminar 1-47
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1 1 1 1
N 1
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
We can match N! because they are the same
POSCAT Seminar 1-48
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1 1 1 1
N 1
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
Then, the LCS must be (LCS between “S” and “SU”) + N
POSCAT Seminar 1-49
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1 1 1 1
N 1
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
Therefore, we get SN. In addition, the value of this entry is 2
POSCAT Seminar 1-50
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1 1 1 1
N 1 2
N
Y
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
Can you see the recurrence relation ?
POSCAT Seminar 1-51
9 July 2014
yougatup
S N O W Y
S 1 1 1 1 1
U 1 1 1 1 1
N 1 2 2 2 2
N 1 2 2 2 2
Y 1 2 2 2 3
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
2. Find a recurrence relation
POSCAT Seminar 1-52
9 July 2014
yougatup
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
2. Find a recurrence relation
𝑇 𝑖, 𝑗 = 𝑇 𝑖 − 1, 𝑗 − 1 + 1 𝑖𝑓 𝑎𝑖 = 𝑏𝑗
max 𝑇 𝑖 − 1, 𝑗 , 𝑇 𝑖, 𝑗 − 1 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
POSCAT Seminar 1-53
9 July 2014
yougatup
Longest Common Subsequence
 Problem
Find an Longest Common Subsequence
S N O W Y
S U N N Y
3. Calculate !
Think about backtrace. It will be easy if you understand DP well.
POSCAT Seminar 1-54
9 July 2014
yougatup
Dynamic Programming
 Remember. 3 step is enough.
− The first step is the most important thing. Finding the
recurrence relation is not that hard commonly.
− I showed somewhat detail explanation of solving procedure
because it is first time to you
− From the next time, I will just let you know what the definition
of Table and the recurrent relation is
 Please solve all the problem
POSCAT Seminar 1-55
9 July 2014
yougatup

More Related Content

Viewers also liked

Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...
Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...
Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...
ijrap
 
Proyecto alegebra andres pastaz 2
Proyecto alegebra andres pastaz 2Proyecto alegebra andres pastaz 2
Proyecto alegebra andres pastaz 2
Andres Pastaz Chicaiza
 
Uuidはどこまでuuidか試してみた
Uuidはどこまでuuidか試してみたUuidはどこまでuuidか試してみた
Uuidはどこまでuuidか試してみた
Yu Yamada
 
The Right Type of Cloud Messaging
The Right Type of Cloud MessagingThe Right Type of Cloud Messaging
The Right Type of Cloud Messaging
Francisco "Cocoy" Claravall
 
8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
mansab MIRZA
 
Docker超入門
Docker超入門Docker超入門
Docker超入門
Katsunori Kanda
 
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
Madhu Bala
 
Attributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programmingAttributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programming
LearnNowOnline
 
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
Amrinder Arora
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
Amrinder Arora
 
(floyd's algm)
(floyd's algm)(floyd's algm)
(floyd's algm)
Jothi Lakshmi
 
AVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsAVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronics
Mohamed Ali
 

Viewers also liked (15)

Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...
Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...
Analytical Solution Of Schrödinger Equation With Mie–Type Potential Using Fac...
 
Proyecto alegebra andres pastaz 2
Proyecto alegebra andres pastaz 2Proyecto alegebra andres pastaz 2
Proyecto alegebra andres pastaz 2
 
Uuidはどこまでuuidか試してみた
Uuidはどこまでuuidか試してみたUuidはどこまでuuidか試してみた
Uuidはどこまでuuidか試してみた
 
The Right Type of Cloud Messaging
The Right Type of Cloud MessagingThe Right Type of Cloud Messaging
The Right Type of Cloud Messaging
 
8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil8. Graph - Data Structures using C++ by Varsha Patil
8. Graph - Data Structures using C++ by Varsha Patil
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
 
Docker超入門
Docker超入門Docker超入門
Docker超入門
 
DP
DPDP
DP
 
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil1. Fundamental Concept - Data Structures using C++ by Varsha Patil
1. Fundamental Concept - Data Structures using C++ by Varsha Patil
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Attributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programmingAttributes, reflection, and dynamic programming
Attributes, reflection, and dynamic programming
 
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and ...
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
(floyd's algm)
(floyd's algm)(floyd's algm)
(floyd's algm)
 
AVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsAVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronics
 

Similar to Poscat seminar 7

Poscat seminar 8
Poscat seminar 8Poscat seminar 8
Poscat seminar 8
Hyungyu Shin
 
Poscat seminar 11
Poscat seminar 11Poscat seminar 11
Poscat seminar 11
Hyungyu Shin
 
Poscat seminar 2
Poscat seminar 2Poscat seminar 2
Poscat seminar 2
Hyungyu Shin
 
An alternative learning experience in transition level mathematics
An alternative learning experience in transition level mathematicsAn alternative learning experience in transition level mathematics
An alternative learning experience in transition level mathematics
Dann Mallet
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
Hyungyu Shin
 
Andrew Daws - Final Project Report
Andrew Daws - Final Project ReportAndrew Daws - Final Project Report
Andrew Daws - Final Project ReportAndrew Daws
 
Poscat seminar 3-1
Poscat seminar 3-1Poscat seminar 3-1
Poscat seminar 3-1
Hyungyu Shin
 
TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...
TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...
TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...
SOURAV DAS
 
Poscat seminar 6
Poscat seminar 6Poscat seminar 6
Poscat seminar 6
Hyungyu Shin
 
Dobson michael pag 52 106
Dobson michael pag 52 106Dobson michael pag 52 106
Dobson michael pag 52 106
alextm76
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
epamspb
 
Power Full Exposition
Power Full ExpositionPower Full Exposition
Power Full ExpositionHeesu Hwang
 
Poscat seminar 9
Poscat seminar 9Poscat seminar 9
Poscat seminar 9
Hyungyu Shin
 
Syam critical path cpa
Syam critical path cpaSyam critical path cpa
Syam critical path cpasyamputra
 
Predict saturated thickness using tensor board visualization
Predict saturated thickness using tensor board visualizationPredict saturated thickness using tensor board visualization
Predict saturated thickness using tensor board visualization
Vinh Nguyen
 
Poscat seminar 5
Poscat seminar 5Poscat seminar 5
Poscat seminar 5
Hyungyu Shin
 
BSOP 330 TUTOR Real Education / bsop330tutor.com
BSOP 330 TUTOR Real Education / bsop330tutor.comBSOP 330 TUTOR Real Education / bsop330tutor.com
BSOP 330 TUTOR Real Education / bsop330tutor.com
munnaq7
 
The Scientific Method
The Scientific MethodThe Scientific Method
The Scientific Method
tscheuch
 

Similar to Poscat seminar 7 (20)

Poscat seminar 8
Poscat seminar 8Poscat seminar 8
Poscat seminar 8
 
Poscat seminar 11
Poscat seminar 11Poscat seminar 11
Poscat seminar 11
 
Poscat seminar 2
Poscat seminar 2Poscat seminar 2
Poscat seminar 2
 
An alternative learning experience in transition level mathematics
An alternative learning experience in transition level mathematicsAn alternative learning experience in transition level mathematics
An alternative learning experience in transition level mathematics
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
 
Andrew Daws - Final Project Report
Andrew Daws - Final Project ReportAndrew Daws - Final Project Report
Andrew Daws - Final Project Report
 
Poscat seminar 3-1
Poscat seminar 3-1Poscat seminar 3-1
Poscat seminar 3-1
 
Pert2
Pert2Pert2
Pert2
 
TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...
TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...
TEXTBOOK ON MATHEMATICAL ECONOMICS FOR CU , BU CALCUTTA , SOLVED EXERCISES , ...
 
Poscat seminar 6
Poscat seminar 6Poscat seminar 6
Poscat seminar 6
 
Dobson michael pag 52 106
Dobson michael pag 52 106Dobson michael pag 52 106
Dobson michael pag 52 106
 
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
#ITsubbotnik Spring 2017: Mikhail Khludnev "Search like %SQL%"
 
Power Full Exposition
Power Full ExpositionPower Full Exposition
Power Full Exposition
 
Poscat seminar 9
Poscat seminar 9Poscat seminar 9
Poscat seminar 9
 
NATE_Oct17_2015_Schwieterman
NATE_Oct17_2015_SchwietermanNATE_Oct17_2015_Schwieterman
NATE_Oct17_2015_Schwieterman
 
Syam critical path cpa
Syam critical path cpaSyam critical path cpa
Syam critical path cpa
 
Predict saturated thickness using tensor board visualization
Predict saturated thickness using tensor board visualizationPredict saturated thickness using tensor board visualization
Predict saturated thickness using tensor board visualization
 
Poscat seminar 5
Poscat seminar 5Poscat seminar 5
Poscat seminar 5
 
BSOP 330 TUTOR Real Education / bsop330tutor.com
BSOP 330 TUTOR Real Education / bsop330tutor.comBSOP 330 TUTOR Real Education / bsop330tutor.com
BSOP 330 TUTOR Real Education / bsop330tutor.com
 
The Scientific Method
The Scientific MethodThe Scientific Method
The Scientific Method
 

Recently uploaded

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 

Recently uploaded (20)

CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 

Poscat seminar 7

  • 1. POSCAT Seminar 7 : Dynamic Programming 1 yougatup @ POSCAT 1
  • 2. Topic  Topic today − Dynamic Programming • Basic Concept • Longest Increasing Subsequence • Longest Common Subsequence POSCAT Seminar 1-2 9 July 2014 yougatup
  • 3. Dynamic Programming  Problem Solving Paradigm − Identifying a collection of subproblems − Tackling them one by one • smallest first • using the answer already calculated to help figure out the larger ones • until the whole problem is solved  One of the most prominent issue − You can be familiar with PS with Dynamic Programming − There are so many issues to cover POSCAT Seminar 1-3 9 July 2014 yougatup
  • 4. Dynamic Programming  Procedure 1. Define the Table 2. Find recurrence relation 3. Calculate ! POSCAT Seminar 1-4 9 July 2014 yougatup
  • 5. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 POSCAT Seminar 1-5 9 July 2014 yougatup
  • 6. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 POSCAT Seminar 1-6 9 July 2014 yougatup
  • 7. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table POSCAT Seminar 1-7 9 July 2014 yougatup
  • 8. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table Let 𝑇(𝑖) = The length of LIS when 𝑎𝑖 is the last element ∴ 𝑎𝑖 have to be last element of subsequence POSCAT Seminar 1-8 9 July 2014 yougatup
  • 9. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table You can fill the table manually. What is the answer ? POSCAT Seminar 1-9 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 10. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table Can you see the recurrence relation on 𝑇 ? POSCAT Seminar 1-10 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 11. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table Suppose that 𝑗 < 𝑖 and 𝐷𝑎𝑡𝑎 𝑗 < 𝐷𝑎𝑡𝑎(𝑖). Then we can add one more element to Increasing Subsequence whose last element is 𝐷𝑎𝑡𝑎(𝑗) POSCAT Seminar 1-11 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 12. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table Consider element 6 in the example. POSCAT Seminar 1-12 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 13. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table We can make a Increasing Subsequence by adding 6 whose last element is 5. ∴ we can make “5 6” POSCAT Seminar 1-13 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 14. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table However, we can make another Increasing Subsequence by considering 2 ! Still the length is 2 POSCAT Seminar 1-14 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 15. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table We can’t make IS with 8 because 8 > 6 POSCAT Seminar 1-15 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 16. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table We can’t POSCAT Seminar 1-16 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 17. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 1. Define the Table We can make ! Therefore, our length is 3. Note that we considered all the case. POSCAT Seminar 1-17 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 18. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 2. Find a recurrence relation 𝑇 𝑖 = max 𝑇 𝑗 + 1 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑗 < 𝑖 & 𝐷𝑎𝑡𝑎 𝑗 < 𝐷𝑎𝑡𝑎(𝑖) POSCAT Seminar 1-18 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 19. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 3. Calculate ! You have to think about where the answer is POSCAT Seminar 1-19 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 20. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 3. Calculate ! You have to think about where the answer is It must be the maximum value of whole Table POSCAT Seminar 1-20 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 21. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Well, we can calculate the length of LIS. Can we find subsequence itself? i.e. “2 3 6 9” in the example. POSCAT Seminar 1-21 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 22. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Well, we can calculate the length of LIS. Can we find subsequence itself? i.e. “2 3 6 9” in the example. That’s possible by writing history ! POSCAT Seminar 1-22 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 23. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 What is the answer on this example ? POSCAT Seminar 1-23 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 24. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 What is the answer on this example ? POSCAT Seminar 1-24 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 25. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 What is the answer on this example ? Then the last element of LIS must be 9 because the definition of 𝑇(𝑖) said that 𝑎𝑖 should be the last element ! POSCAT Seminar 1-25 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 26. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Well, 9 is definitely last element of LIS. How about other elements on LIS ? POSCAT Seminar 1-26 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 27. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Well, 9 is definitely last element of LIS. How about other elements on LIS ? 𝑇(6) is 4 because we add 9 to the end of IS whose last element is 6 POSCAT Seminar 1-27 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 28. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Therefore, 6 have to be located on the left of 9 POSCAT Seminar 1-28 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 29. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Therefore, 6 have to be located on the left of 9 Repeat this procedure until we have no former element POSCAT Seminar 1-29 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4
  • 30. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Therefore, 6 have to be located on the left of 9 Repeat this procedure until we have no former element POSCAT Seminar 1-30 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4 It has no former element !
  • 31. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 We call this procedure as “Backtrace” To implement Backtrace, we have to write down the history. POSCAT Seminar 1-31 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4 Hist. None None 1 1 1 4 5 5 It means that former element of 𝑎5 is 𝑎4 !
  • 32. Longest Increasing Subsequence  Problem Find an increasing subsequence of greatest length 5 2 8 6 3 6 9 7 Implement it . It is very easy to make a stress of yours POSCAT Seminar 1-32 9 July 2014 yougatup index 0 1 2 3 4 5 6 7 Data 5 2 8 6 3 6 9 7 Table 1 1 2 2 2 3 4 4 Hist. None None 1 1 1 4 5 5
  • 33. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y POSCAT Seminar 1-33 9 July 2014 yougatup
  • 34. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y POSCAT Seminar 1-34 9 July 2014 yougatup
  • 35. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y 1. Define the Table Give me ! POSCAT Seminar 1-35 9 July 2014 yougatup
  • 36. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y 1. Define the Table Let 𝑇(𝑖, 𝑗) = The length of LCS between (𝑎1~ 𝑎𝑖) and (𝑏1~ 𝑏𝑗) POSCAT Seminar 1-36 9 July 2014 yougatup
  • 37. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y 1. Define the Table Fill it manually ! POSCAT Seminar 1-37 9 July 2014 yougatup S N O W Y S U N N Y
  • 38. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y 1. Define the Table How can we feel it ? POSCAT Seminar 1-38 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y
  • 39. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y Consider this situation. POSCAT Seminar 1-39 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y
  • 40. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y First of all, we can’t “match” O and U because they are different POSCAT Seminar 1-40 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y
  • 41. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y Therefore, we can remove one or both element POSCAT Seminar 1-41 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y
  • 42. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y What is the length of LCS when we remove O ? POSCAT Seminar 1-42 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y
  • 43. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y What is the length of LCS when we remove O ? POSCAT Seminar 1-43 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y It knows !
  • 44. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y What is the length of LCS when we remove U ? POSCAT Seminar 1-44 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y
  • 45. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y What is the length of LCS when we remove U ? POSCAT Seminar 1-45 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 N N Y It has !
  • 46. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y Therefore, the value of this entry is 1 POSCAT Seminar 1-46 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 1 N N Y
  • 47. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y How about this situation ? POSCAT Seminar 1-47 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 1 1 1 N 1 N Y
  • 48. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y We can match N! because they are the same POSCAT Seminar 1-48 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 1 1 1 N 1 N Y
  • 49. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y Then, the LCS must be (LCS between “S” and “SU”) + N POSCAT Seminar 1-49 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 1 1 1 N 1 N Y
  • 50. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y Therefore, we get SN. In addition, the value of this entry is 2 POSCAT Seminar 1-50 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 1 1 1 N 1 2 N Y
  • 51. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y Can you see the recurrence relation ? POSCAT Seminar 1-51 9 July 2014 yougatup S N O W Y S 1 1 1 1 1 U 1 1 1 1 1 N 1 2 2 2 2 N 1 2 2 2 2 Y 1 2 2 2 3
  • 52. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y 2. Find a recurrence relation POSCAT Seminar 1-52 9 July 2014 yougatup
  • 53. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y 2. Find a recurrence relation 𝑇 𝑖, 𝑗 = 𝑇 𝑖 − 1, 𝑗 − 1 + 1 𝑖𝑓 𝑎𝑖 = 𝑏𝑗 max 𝑇 𝑖 − 1, 𝑗 , 𝑇 𝑖, 𝑗 − 1 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒 POSCAT Seminar 1-53 9 July 2014 yougatup
  • 54. Longest Common Subsequence  Problem Find an Longest Common Subsequence S N O W Y S U N N Y 3. Calculate ! Think about backtrace. It will be easy if you understand DP well. POSCAT Seminar 1-54 9 July 2014 yougatup
  • 55. Dynamic Programming  Remember. 3 step is enough. − The first step is the most important thing. Finding the recurrence relation is not that hard commonly. − I showed somewhat detail explanation of solving procedure because it is first time to you − From the next time, I will just let you know what the definition of Table and the recurrent relation is  Please solve all the problem POSCAT Seminar 1-55 9 July 2014 yougatup