際際滷

際際滷Share a Scribd company logo
Ch 09.  螻覯 
Dynamic Programming
PNU ALCALL 2017 SUMMER
1
覦覲旧  螻覯
9.21
PNU ALCALL 2017 SUMMER
2
覦覲旧  螻覯
Iterative Dynamic Programming
覦覲給(覲危 for) 磯 DP
PNU ALCALL 2017 SUMMER
3
覦覲旧
覦覲旧  螻覯
PNU ALCALL 2017 SUMMER
4
譟伎   螻
= 覿覿蟲譟郁 伎
 : 手  豕 蟆暑
PNU ALCALL 2017 SUMMER
5
@algospot.com
 : 手  豕 蟆暑
PNU ALCALL 2017 SUMMER
6
@algospot.com
 : 手  豕 蟆暑
PNU ALCALL 2017 SUMMER
7
Path2(y,x) = triangle[y,x] + max
≠2( + 1, )
≠2( + 1,  + 1)
覃覈伎伎 : Path2(y,x) 襯 語 -> Memo[y, x] 覓  -> 蟆郁骸螳 覦 (Top-down)
覦覲旧 DP : C[y,x] 覦襦 螳  
( = Path2(y,x)襯 螻壱蠍  螳(Path2(y+1,x+1), Path2(y+1,x)) 企 螻 伎. )
(Bottom-up)
 : 手  豕 蟆暑
PNU ALCALL 2017 SUMMER
8
殊企 
PNU ALCALL 2017 SUMMER
9
6
1 2
3 7 4
9 4 1 7
2 7 5 9 4
16 11 10 16
19 18 20
20 22
28
螻一螳 殊覩襦 螳
殊企 
PNU ALCALL 2017 SUMMER
10
朱慨豺 襷讌襷 5襴 DP
PNU ALCALL 2017 SUMMER
11
朱慨豺 襷讌襷 5襴 DP
PNU ALCALL 2017 SUMMER
12
駒 =
(  1)
()
駒+1 =
()
( + 1)
=
()
   1 + ()
=
駒,1
駒,0 + 駒,1
=
0 1
1 1
駒
  =
0 1
1 1
1
1
朱慨豺 襷讌襷 5襴 DP
PNU ALCALL 2017 SUMMER
13
 =
0 1
1 1
 
=  /2
  /2
O(log n)
朱
PNU ALCALL 2017 SUMMER
14
     A  蟆壱朱  DP 螻襴讀
 螳覲旧°O(2)
  觜襯 蟇磯螻煙 覃 O(3 log )
 M 蠍一 磯殊 豬
蠏 vs 覦覲給
PNU ALCALL 2017 SUMMER
15
 蠏 ル
レ : 讌蟯 貊. 譟願螻 螻一 覓願.
 : 螻糾觜螳 . Call Stack Overflow 覦.
 覦覲給語 ル
レ : 讌ъ 貊. Call Stack 覿 X. 螻糾 (殊企 
)
 : 蟲 觜讌蟯願 螻一 レ 襷 覦.
覓語 : 豐覦
9.22
PNU ALCALL 2017 SUMMER
16
覓語 る
PNU ALCALL 2017 SUMMER
17
覓語 る
PNU ALCALL 2017 SUMMER
18
覓語 : 豐覦 
9.22
PNU ALCALL 2017 SUMMER
19
Knapsack
PNU ALCALL 2017 SUMMER
20
 覦磯 豈郁鍵 覓語 
伎 覓願襯 讌 朱伎 豕 螳豺襯 谿剰鍵
VS
伎 磯ゼ 讌 朱伎 豕 碁襯 谿剰鍵
谿伎
PNU ALCALL 2017 SUMMER
21
 譴覲給 豐覦レ 螳瑚  
 M < 10^9 碁  DP 企 蠍 : N x M
-> 殊企 磯 覦一危蠍磯ゼ 譴企蟆 蟯蟇
殊企 
PNU ALCALL 2017 SUMMER
22
 T[i][j] = i覯 豐覦ル 蟆曙郁   j朱 襾轟   豕 蠍
企 蠍 20 * 10^9 (20000MB)
 i:0->N
Prev[j] : i-1 覯 豐覦リ讌 襾轟  豕 碁
T[j] : i覯豐覦リ讌 襾轟  豕 碁
T[j] = max(T[j],T[j  price[i]]+ price[i]])
 螳蟆 螳 100企襦 100朱 譴 螳 index襦
れ
PNU ALCALL 2017 SUMMER
23
PNU ALCALL 2017 SUMMER
24
Q&A
FIN

More Related Content

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools

Dynamic Programming

  • 1. Ch 09. 螻覯 Dynamic Programming PNU ALCALL 2017 SUMMER 1
  • 2. 覦覲旧 螻覯 9.21 PNU ALCALL 2017 SUMMER 2
  • 3. 覦覲旧 螻覯 Iterative Dynamic Programming 覦覲給(覲危 for) 磯 DP PNU ALCALL 2017 SUMMER 3 覦覲旧
  • 4. 覦覲旧 螻覯 PNU ALCALL 2017 SUMMER 4 譟伎 螻 = 覿覿蟲譟郁 伎
  • 5. : 手 豕 蟆暑 PNU ALCALL 2017 SUMMER 5 @algospot.com
  • 6. : 手 豕 蟆暑 PNU ALCALL 2017 SUMMER 6 @algospot.com
  • 7. : 手 豕 蟆暑 PNU ALCALL 2017 SUMMER 7 Path2(y,x) = triangle[y,x] + max ≠2( + 1, ) ≠2( + 1, + 1) 覃覈伎伎 : Path2(y,x) 襯 語 -> Memo[y, x] 覓 -> 蟆郁骸螳 覦 (Top-down) 覦覲旧 DP : C[y,x] 覦襦 螳 ( = Path2(y,x)襯 螻壱蠍 螳(Path2(y+1,x+1), Path2(y+1,x)) 企 螻 伎. ) (Bottom-up)
  • 8. : 手 豕 蟆暑 PNU ALCALL 2017 SUMMER 8
  • 9. 殊企 PNU ALCALL 2017 SUMMER 9 6 1 2 3 7 4 9 4 1 7 2 7 5 9 4 16 11 10 16 19 18 20 20 22 28 螻一螳 殊覩襦 螳
  • 10. 殊企 PNU ALCALL 2017 SUMMER 10
  • 11. 朱慨豺 襷讌襷 5襴 DP PNU ALCALL 2017 SUMMER 11
  • 12. 朱慨豺 襷讌襷 5襴 DP PNU ALCALL 2017 SUMMER 12 駒 = ( 1) () 駒+1 = () ( + 1) = () 1 + () = 駒,1 駒,0 + 駒,1 = 0 1 1 1 駒 = 0 1 1 1 1 1
  • 13. 朱慨豺 襷讌襷 5襴 DP PNU ALCALL 2017 SUMMER 13 = 0 1 1 1 = /2 /2 O(log n)
  • 14. 朱 PNU ALCALL 2017 SUMMER 14 A 蟆壱朱 DP 螻襴讀 螳覲旧°O(2) 觜襯 蟇磯螻煙 覃 O(3 log ) M 蠍一 磯殊 豬
  • 15. 蠏 vs 覦覲給 PNU ALCALL 2017 SUMMER 15 蠏 ル レ : 讌蟯 貊. 譟願螻 螻一 覓願. : 螻糾觜螳 . Call Stack Overflow 覦. 覦覲給語 ル レ : 讌ъ 貊. Call Stack 覿 X. 螻糾 (殊企 ) : 蟲 觜讌蟯願 螻一 レ 襷 覦.
  • 16. 覓語 : 豐覦 9.22 PNU ALCALL 2017 SUMMER 16
  • 17. 覓語 る PNU ALCALL 2017 SUMMER 17
  • 18. 覓語 る PNU ALCALL 2017 SUMMER 18
  • 19. 覓語 : 豐覦 9.22 PNU ALCALL 2017 SUMMER 19
  • 20. Knapsack PNU ALCALL 2017 SUMMER 20 覦磯 豈郁鍵 覓語 伎 覓願襯 讌 朱伎 豕 螳豺襯 谿剰鍵 VS 伎 磯ゼ 讌 朱伎 豕 碁襯 谿剰鍵
  • 21. 谿伎 PNU ALCALL 2017 SUMMER 21 譴覲給 豐覦レ 螳瑚 M < 10^9 碁 DP 企 蠍 : N x M -> 殊企 磯 覦一危蠍磯ゼ 譴企蟆 蟯蟇
  • 22. 殊企 PNU ALCALL 2017 SUMMER 22 T[i][j] = i覯 豐覦ル 蟆曙郁 j朱 襾轟 豕 蠍 企 蠍 20 * 10^9 (20000MB) i:0->N Prev[j] : i-1 覯 豐覦リ讌 襾轟 豕 碁 T[j] : i覯豐覦リ讌 襾轟 豕 碁 T[j] = max(T[j],T[j price[i]]+ price[i]]) 螳蟆 螳 100企襦 100朱 譴 螳 index襦
  • 23. れ PNU ALCALL 2017 SUMMER 23
  • 24. PNU ALCALL 2017 SUMMER 24 Q&A FIN