Poscat seminar 8
-
Upload
hyungyu-shin -
Category
Education
-
view
121 -
download
0
Transcript of Poscat seminar 8
![Page 1: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/1.jpg)
POSCAT Seminar 8 :Dynamic Programming 2
yougatup @ POSCAT
1
![Page 2: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/2.jpg)
Topic
Topic today
− Dynamic Programming
• Longest Palindrome
• Team Division
POSCAT Seminar 1-29 July 2014
yougatup
![Page 3: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/3.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
POSCAT Seminar 1-39 July 2014
yougatup
![Page 4: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/4.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
POSCAT Seminar 1-49 July 2014
yougatup
![Page 5: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/5.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
1. Define the Table
POSCAT Seminar 1-59 July 2014
yougatup
![Page 6: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/6.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
1. Define the Table
let 𝑇 𝑖, 𝑗 = the length of longest palindrome on 𝑎𝑖 ~ 𝑎𝑗
POSCAT Seminar 1-69 July 2014
yougatup
![Page 7: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/7.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
2. Find a recurrence relation
POSCAT Seminar 1-79 July 2014
yougatup
![Page 8: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/8.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
2. Find a recurrence relation
Consider the case when 𝑎𝑖 = 𝑎𝑗 or not
POSCAT Seminar 1-89 July 2014
yougatup
![Page 9: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/9.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
2. Find a recurrence relation
𝑇 𝑖, 𝑗 = 𝑇 𝑖 + 1, 𝑗 − 1 + 2 𝑖𝑓 𝑎𝑖 = 𝑎𝑗
max 𝑇 𝑖 + 1, 𝑗 , 𝑇 𝑖, 𝑗 − 1 𝑜𝑡ℎ𝑒𝑟𝑤𝑖𝑠𝑒
POSCAT Seminar 1-99 July 2014
yougatup
![Page 10: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/10.jpg)
Longest Palindrome
Problem
A palindrome is a word that reads the same forward or reversed
Given string, find the length of longest palindrome among the
subsequence.
b a b a c v a b b a
3. Calculate !
Think carefully about the filling direction
POSCAT Seminar 1-109 July 2014
yougatup
![Page 11: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/11.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
For example, let 𝑚 = 3
1 2 5 3 4 2 6 7 3 4
POSCAT Seminar 1-119 July 2014
yougatup
![Page 12: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/12.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
For example, let 𝑚 = 3
1 2 / 5 3 4 2 6 / 7 3 4
POSCAT Seminar 1-129 July 2014
yougatup
![Page 13: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/13.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
For example, let 𝑚 = 3
1 2 / 5 3 4 2 6 / 7 3 4
3 20 14
POSCAT Seminar 1-139 July 2014
yougatup
![Page 14: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/14.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
For example, let 𝑚 = 3
1 2 / 5 3 4 2 6 / 7 3 4
3 20 14
∴ we get 20
POSCAT Seminar 1-149 July 2014
yougatup
![Page 15: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/15.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
For example, let 𝑚 = 3
1 2 5 3 / 4 2 6 / 7 3 4
POSCAT Seminar 1-159 July 2014
yougatup
![Page 16: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/16.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
For example, let 𝑚 = 3
1 2 5 3 / 4 2 6 / 7 3 4
11 12 14
POSCAT Seminar 1-169 July 2014
yougatup
![Page 17: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/17.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
For example, let 𝑚 = 3
1 2 5 3 / 4 2 6 / 7 3 4
11 12 14
∴ we get 14 much better !
POSCAT Seminar 1-179 July 2014
yougatup
![Page 18: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/18.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
1. Define the Table
POSCAT Seminar 1-189 July 2014
yougatup
![Page 19: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/19.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
1. Define the Table
𝑇 𝑖, 𝑗 = the minimum value when we divide 𝑎1 ~ 𝑎𝑗 into 𝑖
chunks
POSCAT Seminar 1-199 July 2014
yougatup
![Page 20: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/20.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
2. Find a recurrence relation
POSCAT Seminar 1-209 July 2014
yougatup
![Page 21: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/21.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
2. Find a recurrence relation
𝑇 𝑖, 𝑗 = min(max( 𝑇 𝑖 − 1, 𝑘 , 𝐶𝑜𝑠𝑡 𝑘 + 1, 𝑗 ) )
𝑓𝑜𝑟 𝑎𝑙𝑙 𝑖 ≤ 𝑘 ≤ 𝑗
After making i-1 chunks from 𝑎1 ~ 𝑎𝑘,make ONE chunk as
𝑎𝑘+1 ~ 𝑎𝑗 for all possible k.
POSCAT Seminar 1-219 July 2014
yougatup
![Page 22: Poscat seminar 8](https://reader031.fdocuments.us/reader031/viewer/2022030316/5876d44f1a28ab1d238b538d/html5/thumbnails/22.jpg)
Team Division
Problem
Suppose that we can divide 𝑛 numbers into 𝑚 chunks.
Minimize the maximum value of sum of each chunk.
3. Calculate !
POSCAT Seminar 1-229 July 2014
yougatup