SlideShare a Scribd company logo
POSCAT Seminar 5 :
Recursion and Divide & Conquer
yougatup @ POSCAT
1
Topic
 Topic today
− Recursion
• Basic Concept
− Divide & Conquer
• Basic Concept
• Finding Medians
• Closest Pair
• Implementation
POSCAT Seminar 1-2
2 July 2014
yougatup
By the way, do you solve all the problems ?
You should already know
what recursion is !
POSCAT Seminar 1-3
2 July 2014
yougatup
Divide & Conquer
 Problem Solving Paradigm
1. Break the problem into subproblems : smaller instances
2. Solve them recursively
3. Combine the solutions to get the answer to the problem.
 Calculation of time complexity is not trivial
− We need Master theorem to calculate it
− Recurrence relation
− Not that important now
POSCAT Seminar 1-4
2 July 2014
yougatup
Finding Medians and Selection
 Problem
Find the k-th smallest element in S, where S is a set of numbers
POSCAT Seminar 1-5
2 July 2014
yougatup
Finding Medians and Selection
 Problem
Find the k-th smallest element in S, where S is a set of numbers
Naïve approach : Sort it ! O(𝑛 log 𝑛)
POSCAT Seminar 1-6
2 July 2014
yougatup
Finding Medians and Selection
 Problem
Find the k-th smallest element in S, where S is a set of numbers
Naïve approach : Sort it ! O(𝑛 log 𝑛)
Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 !
POSCAT Seminar 1-7
2 July 2014
yougatup
Finding Medians and Selection
 Problem
Find the k-th smallest element in S, where S is a set of numbers
Naïve approach : Sort it ! O(𝑛 log 𝑛)
Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 !
POSCAT Seminar 1-8
2 July 2014
yougatup
Finding Medians and Selection
 Problem
Find the k-th smallest element in S, where S is a set of numbers
Naïve approach : Sort it ! O(𝑛 log 𝑛)
Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 !
We have to choose 𝑣 nicely ! … How ?
POSCAT Seminar 1-9
2 July 2014
yougatup
Finding Medians and Selection
 Problem
Find the k-th smallest element in S, where S is a set of numbers
Naïve approach : Sort it ! O(𝑛 log 𝑛)
Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 !
We have to choose 𝑣 nicely ! … How ?
POSCAT Seminar 1-10
2 July 2014
yougatup
Randomly !
Finding Medians and Selection
 Problem
If we’re lucky, then the partition goes to small very fast. If not,
It will take O(𝑛2
). Can we trust random choice of 𝑣 ?
POSCAT Seminar 1-11
2 July 2014
yougatup
Finding Medians and Selection
 Problem
If we’re lucky, then the partition goes to small very fast. If not,
It will take O(𝑛2
). Can we trust random choice of 𝑣 ?
Yes! because the worst case is extremely unlike to occur !
There are 50% chance of being good, that is, the Sublists 𝑆 𝐿 and
𝑆 𝑅 have size at most ¾ of that of S.
POSCAT Seminar 1-12
2 July 2014
yougatup
Finding Medians and Selection
 Problem
If we’re lucky, then the partition goes to small very fast. If not,
It will take O(𝑛2
). Can we trust random choice of 𝑣 ?
Therefore, the expected running time T(𝑛) is
T(𝑛) ≤ T(3𝑛/4) + O(𝑐 ⋅ 𝑛)
where 𝑐 is the average number of consecutive splits to find a
good split. Clearly 𝑐 = 2. So we can conclude that T(𝑛) = O(𝑛)
POSCAT Seminar 1-13
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
POSCAT Seminar 1-14
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
Brute force approach : Check all pairs of points. O(𝑛2)
POSCAT Seminar 1-15
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
Divide & Conquer approach
1. Split points into two groups
2. Find closest pair of points for each group
3. Combine the solutions !
POSCAT Seminar 1-16
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
1. Split points into two group
POSCAT Seminar 1-17
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
1. Split points into two group
POSCAT Seminar 1-18
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
2. Find closest pair of points for each group
POSCAT Seminar 1-19
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
3. Combine the solutions ?
POSCAT Seminar 1-20
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
3. Combine the solutions ?
POSCAT Seminar 1-21
2 July 2014
yougatup
Is it enough to choose
small one between two solutions ?
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
3. Combine the solutions ?
POSCAT Seminar 1-22
2 July 2014
yougatup
Is it enough to choose
small one between two solutions ?
We didn’t consider it
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
3. Combine the solutions ?
POSCAT Seminar 1-23
2 July 2014
yougatup
Then, do we have to consider all the cases
when a pair consists of a point in the left
and a point in the right ?
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
3. Combine the solutions ?
POSCAT Seminar 1-24
2 July 2014
yougatup
Then, do we have to consider all the cases
when a pair consists of a point in the left
and a point in the right ?
No! because we have partial solution !
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
Idea : If a closer pair is exist, then it must be in the grey region
POSCAT Seminar 1-25
2 July 2014
yougatup
𝛿
𝛿 𝛿
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
Idea : If a closer pair is exist, then it must be in the grey region
POSCAT Seminar 1-26
2 July 2014
yougatup
𝛿
𝛿 𝛿 Still, worst case can happen
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
Claim. If 𝑖 − 𝑗 ≥ 12, then the distance
between 𝑝𝑖 and 𝑝𝑗 is at least 𝛿
• No two points lie in same 𝛿/2-by-𝛿/2 box.
• Two points at least 2 rows apart
have distance ≥ 2(𝛿/2)
Therefore, it is sufficient to consider 12 points
above me !
POSCAT Seminar 1-27
2 July 2014
yougatup
Closest pair of points
 Problem
Given 𝑛 points in the plane, find a pair with smallest Euclidean
distance between them.
Claim. If 𝑖 − 𝑗 ≥ 12, then the distance
between 𝑝𝑖 and 𝑝𝑗 is at least 𝛿
• No two points lie in same 𝛿/2-by-𝛿/2 box.
• Two points at least 2 rows apart
have distance ≥ 2(𝛿/2)
Therefore, it is sufficient to consider 12 points
above me ! ∴ T(𝑛) = 2T(𝑛/2) + O(𝑛) = O(𝒏 𝐥𝐨𝐠 𝒏)
POSCAT Seminar 1-28
2 July 2014
yougatup

More Related Content

What's hot

MAP101 Fundamentals of Singapore Mathematics Curriculum
MAP101 Fundamentals of Singapore Mathematics Curriculum MAP101 Fundamentals of Singapore Mathematics Curriculum
MAP101 Fundamentals of Singapore Mathematics Curriculum
Jimmy Keng
 
Probsolvwebquest
ProbsolvwebquestProbsolvwebquest
Probsolvwebquest
JC Sawyer Dolphins
 
MCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math InstituteMCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math Institute
Jimmy Keng
 
Blake Grade 1
Blake Grade 1Blake Grade 1
Blake Grade 1
Jimmy Keng
 
MCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math Institute MCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math Institute
Jimmy Keng
 
G6 m4-g-lesson 27-s
G6 m4-g-lesson 27-sG6 m4-g-lesson 27-s
G6 m4-g-lesson 27-s
mlabuski
 
Problem solving strategy: logical reasoning
Problem solving strategy: logical reasoningProblem solving strategy: logical reasoning
Problem solving strategy: logical reasoning
Chuekidz Chukidz
 
AME-SMS Conference 2012 Secondary
AME-SMS Conference 2012 SecondaryAME-SMS Conference 2012 Secondary
AME-SMS Conference 2012 Secondary
Jimmy Keng
 
2nd Grade Singapore Math Training II
2nd Grade Singapore Math Training II2nd Grade Singapore Math Training II
2nd Grade Singapore Math Training II
Kimberly Beane
 
Blake grade 5
Blake grade 5Blake grade 5
Blake grade 5
Jimmy Keng
 
Live Action Math Problem
Live Action Math ProblemLive Action Math Problem
Live Action Math Problem
arudt
 
Module 1 lesson 27
Module 1 lesson 27Module 1 lesson 27
Module 1 lesson 27
mlabuski
 
What makesa mathtaskworthwhileemaol
What makesa mathtaskworthwhileemaolWhat makesa mathtaskworthwhileemaol
What makesa mathtaskworthwhileemaol
kdtanker
 
G6 m4-g-lesson 26-t
G6 m4-g-lesson 26-tG6 m4-g-lesson 26-t
G6 m4-g-lesson 26-t
mlabuski
 
G6 m1-d-lesson 27-t
G6 m1-d-lesson 27-tG6 m1-d-lesson 27-t
G6 m1-d-lesson 27-t
mlabuski
 
T.E.A.C.H. Academy Course 11
T.E.A.C.H. Academy Course 11T.E.A.C.H. Academy Course 11
T.E.A.C.H. Academy Course 11
Jimmy Keng
 
Science presentation
Science presentationScience presentation
Science presentation
Ravin Ravi
 
Lesson plan math 10 2 nd grading
Lesson plan math 10 2 nd gradingLesson plan math 10 2 nd grading
Lesson plan math 10 2 nd grading
Nnelgebar
 
ECM101 Development of Early Childhood Numeracy
ECM101 Development of Early Childhood NumeracyECM101 Development of Early Childhood Numeracy
ECM101 Development of Early Childhood Numeracy
Jimmy Keng
 
New Syllabus Mathematics Seminar 5 Oct
New Syllabus Mathematics Seminar 5 OctNew Syllabus Mathematics Seminar 5 Oct
New Syllabus Mathematics Seminar 5 Oct
Jimmy Keng
 

What's hot (20)

MAP101 Fundamentals of Singapore Mathematics Curriculum
MAP101 Fundamentals of Singapore Mathematics Curriculum MAP101 Fundamentals of Singapore Mathematics Curriculum
MAP101 Fundamentals of Singapore Mathematics Curriculum
 
Probsolvwebquest
ProbsolvwebquestProbsolvwebquest
Probsolvwebquest
 
MCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math InstituteMCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math Institute
 
Blake Grade 1
Blake Grade 1Blake Grade 1
Blake Grade 1
 
MCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math Institute MCI Worchester State University Singapore Math Institute
MCI Worchester State University Singapore Math Institute
 
G6 m4-g-lesson 27-s
G6 m4-g-lesson 27-sG6 m4-g-lesson 27-s
G6 m4-g-lesson 27-s
 
Problem solving strategy: logical reasoning
Problem solving strategy: logical reasoningProblem solving strategy: logical reasoning
Problem solving strategy: logical reasoning
 
AME-SMS Conference 2012 Secondary
AME-SMS Conference 2012 SecondaryAME-SMS Conference 2012 Secondary
AME-SMS Conference 2012 Secondary
 
2nd Grade Singapore Math Training II
2nd Grade Singapore Math Training II2nd Grade Singapore Math Training II
2nd Grade Singapore Math Training II
 
Blake grade 5
Blake grade 5Blake grade 5
Blake grade 5
 
Live Action Math Problem
Live Action Math ProblemLive Action Math Problem
Live Action Math Problem
 
Module 1 lesson 27
Module 1 lesson 27Module 1 lesson 27
Module 1 lesson 27
 
What makesa mathtaskworthwhileemaol
What makesa mathtaskworthwhileemaolWhat makesa mathtaskworthwhileemaol
What makesa mathtaskworthwhileemaol
 
G6 m4-g-lesson 26-t
G6 m4-g-lesson 26-tG6 m4-g-lesson 26-t
G6 m4-g-lesson 26-t
 
G6 m1-d-lesson 27-t
G6 m1-d-lesson 27-tG6 m1-d-lesson 27-t
G6 m1-d-lesson 27-t
 
T.E.A.C.H. Academy Course 11
T.E.A.C.H. Academy Course 11T.E.A.C.H. Academy Course 11
T.E.A.C.H. Academy Course 11
 
Science presentation
Science presentationScience presentation
Science presentation
 
Lesson plan math 10 2 nd grading
Lesson plan math 10 2 nd gradingLesson plan math 10 2 nd grading
Lesson plan math 10 2 nd grading
 
ECM101 Development of Early Childhood Numeracy
ECM101 Development of Early Childhood NumeracyECM101 Development of Early Childhood Numeracy
ECM101 Development of Early Childhood Numeracy
 
New Syllabus Mathematics Seminar 5 Oct
New Syllabus Mathematics Seminar 5 OctNew Syllabus Mathematics Seminar 5 Oct
New Syllabus Mathematics Seminar 5 Oct
 

Viewers also liked

Quality not quantity
Quality not quantityQuality not quantity
Quality not quantity
vanesz
 
Le cordon bleu
Le cordon bleu Le cordon bleu
Le cordon bleu
pastisart
 
Learn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c AdministrationLearn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c Administration
Revelation Technologies
 
Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)
Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)
Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)
Revelation Technologies
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
Hyungyu Shin
 
Financial Risk Management For Manufacturing
Financial Risk Management For ManufacturingFinancial Risk Management For Manufacturing
Financial Risk Management For Manufacturing
Dick Lam
 
Usability - Ignored by Developers and Undervalued by Managers (article)
Usability - Ignored by Developers and Undervalued by Managers (article)Usability - Ignored by Developers and Undervalued by Managers (article)
Usability - Ignored by Developers and Undervalued by Managers (article)
Revelation Technologies
 
Asakusaではじめるhadoop sparkプログラミング
Asakusaではじめるhadoop sparkプログラミングAsakusaではじめるhadoop sparkプログラミング
Asakusaではじめるhadoop sparkプログラミング
Tadatoshi Sekiguchi
 
5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate Implemenations5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate Implemenations
Bobby Curtis
 
Cape fear analysis 2
Cape fear analysis 2Cape fear analysis 2
Cape fear analysis 2
Daisie Mae
 
Osb student guide
Osb student guideOsb student guide
Osb student guide
Vibhor Rastogi
 
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
Swati Swati
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門
uranishi
 
John rawls
John rawlsJohn rawls
John rawls
Iria López
 

Viewers also liked (16)

Quality not quantity
Quality not quantityQuality not quantity
Quality not quantity
 
Le cordon bleu
Le cordon bleu Le cordon bleu
Le cordon bleu
 
Learn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c AdministrationLearn Oracle WebLogic Server 12c Administration
Learn Oracle WebLogic Server 12c Administration
 
Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)
Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)
Oracle SOA Suite 11g Troubleshooting Methodology (whitepaper)
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
 
Financial Risk Management For Manufacturing
Financial Risk Management For ManufacturingFinancial Risk Management For Manufacturing
Financial Risk Management For Manufacturing
 
Usability - Ignored by Developers and Undervalued by Managers (article)
Usability - Ignored by Developers and Undervalued by Managers (article)Usability - Ignored by Developers and Undervalued by Managers (article)
Usability - Ignored by Developers and Undervalued by Managers (article)
 
Asakusaではじめるhadoop sparkプログラミング
Asakusaではじめるhadoop sparkプログラミングAsakusaではじめるhadoop sparkプログラミング
Asakusaではじめるhadoop sparkプログラミング
 
5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate Implemenations5 Keys to Oracle GoldenGate Implemenations
5 Keys to Oracle GoldenGate Implemenations
 
Cape fear analysis 2
Cape fear analysis 2Cape fear analysis 2
Cape fear analysis 2
 
Osb student guide
Osb student guideOsb student guide
Osb student guide
 
5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil5. Queue - Data Structures using C++ by Varsha Patil
5. Queue - Data Structures using C++ by Varsha Patil
 
Longest Common Subsequence
Longest Common SubsequenceLongest Common Subsequence
Longest Common Subsequence
 
15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil15. STL - Data Structures using C++ by Varsha Patil
15. STL - Data Structures using C++ by Varsha Patil
 
OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門OpenCVを用いた画像処理入門
OpenCVを用いた画像処理入門
 
John rawls
John rawlsJohn rawls
John rawls
 

Similar to Poscat seminar 5

Poscat seminar 6
Poscat seminar 6Poscat seminar 6
Poscat seminar 6
Hyungyu Shin
 
Poscat seminar 8
Poscat seminar 8Poscat seminar 8
Poscat seminar 8
Hyungyu Shin
 
Term 3 Week 7
Term 3 Week 7Term 3 Week 7
Term 3 Week 7
room2lis
 
Term 3 Week 7
Term 3 Week 7Term 3 Week 7
Term 3 Week 7
room2lis
 
Module 1 lesson 12 notes
Module 1 lesson 12 notesModule 1 lesson 12 notes
Module 1 lesson 12 notes
mlabuski
 
CO Quadratic Inequalties.pptx
CO Quadratic Inequalties.pptxCO Quadratic Inequalties.pptx
CO Quadratic Inequalties.pptx
ManuelEsponilla
 
Lesson plan 1013 3
Lesson plan 1013 3Lesson plan 1013 3
Lesson plan 1013 3
Erica Tate
 
Poscat seminar 3-1
Poscat seminar 3-1Poscat seminar 3-1
Poscat seminar 3-1
Hyungyu Shin
 
Ece141day8class
Ece141day8classEce141day8class
Ece141day8class
Emily McMason
 
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
 
Solving Equations by Factoring KTIP lesson plan
Solving Equations by Factoring KTIP lesson planSolving Equations by Factoring KTIP lesson plan
Solving Equations by Factoring KTIP lesson plan
Josephine Neff
 
Poscat seminar 7
Poscat seminar 7Poscat seminar 7
Poscat seminar 7
Hyungyu Shin
 
Weeklong Lesson Plan
Weeklong Lesson PlanWeeklong Lesson Plan
Weeklong Lesson Plan
Elise Andrews
 
Monday september 22, 2014
Monday september 22, 2014Monday september 22, 2014
Monday september 22, 2014
kaitg231
 
Module 1 lesson 14
Module 1 lesson 14Module 1 lesson 14
Module 1 lesson 14
Erik Tjersland
 
ATMOPAV 2012
ATMOPAV 2012ATMOPAV 2012
ATMOPAV 2012
Bob Lochel
 
Problem solving content
Problem solving contentProblem solving content
Problem solving content
Timothy Welsh
 
problem_solving in physics
 problem_solving in physics problem_solving in physics
problem_solving in physics
Timothy Welsh
 
Module 2 lesson 6
Module 2 lesson 6Module 2 lesson 6
Module 2 lesson 6
mlabuski
 
Problem Solving Strategies 2016.pdf
Problem Solving Strategies 2016.pdfProblem Solving Strategies 2016.pdf
Problem Solving Strategies 2016.pdf
RhinoMonsalud1
 

Similar to Poscat seminar 5 (20)

Poscat seminar 6
Poscat seminar 6Poscat seminar 6
Poscat seminar 6
 
Poscat seminar 8
Poscat seminar 8Poscat seminar 8
Poscat seminar 8
 
Term 3 Week 7
Term 3 Week 7Term 3 Week 7
Term 3 Week 7
 
Term 3 Week 7
Term 3 Week 7Term 3 Week 7
Term 3 Week 7
 
Module 1 lesson 12 notes
Module 1 lesson 12 notesModule 1 lesson 12 notes
Module 1 lesson 12 notes
 
CO Quadratic Inequalties.pptx
CO Quadratic Inequalties.pptxCO Quadratic Inequalties.pptx
CO Quadratic Inequalties.pptx
 
Lesson plan 1013 3
Lesson plan 1013 3Lesson plan 1013 3
Lesson plan 1013 3
 
Poscat seminar 3-1
Poscat seminar 3-1Poscat seminar 3-1
Poscat seminar 3-1
 
Ece141day8class
Ece141day8classEce141day8class
Ece141day8class
 
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
 
Solving Equations by Factoring KTIP lesson plan
Solving Equations by Factoring KTIP lesson planSolving Equations by Factoring KTIP lesson plan
Solving Equations by Factoring KTIP lesson plan
 
Poscat seminar 7
Poscat seminar 7Poscat seminar 7
Poscat seminar 7
 
Weeklong Lesson Plan
Weeklong Lesson PlanWeeklong Lesson Plan
Weeklong Lesson Plan
 
Monday september 22, 2014
Monday september 22, 2014Monday september 22, 2014
Monday september 22, 2014
 
Module 1 lesson 14
Module 1 lesson 14Module 1 lesson 14
Module 1 lesson 14
 
ATMOPAV 2012
ATMOPAV 2012ATMOPAV 2012
ATMOPAV 2012
 
Problem solving content
Problem solving contentProblem solving content
Problem solving content
 
problem_solving in physics
 problem_solving in physics problem_solving in physics
problem_solving in physics
 
Module 2 lesson 6
Module 2 lesson 6Module 2 lesson 6
Module 2 lesson 6
 
Problem Solving Strategies 2016.pdf
Problem Solving Strategies 2016.pdfProblem Solving Strategies 2016.pdf
Problem Solving Strategies 2016.pdf
 

More from Hyungyu Shin

Poscat seminar 9
Poscat seminar 9Poscat seminar 9
Poscat seminar 9
Hyungyu Shin
 
Poscat seminar 11
Poscat seminar 11Poscat seminar 11
Poscat seminar 11
Hyungyu Shin
 
Poscat seminar 4
Poscat seminar 4Poscat seminar 4
Poscat seminar 4
Hyungyu Shin
 
Poscat seminar 3-2
Poscat seminar 3-2Poscat seminar 3-2
Poscat seminar 3-2
Hyungyu Shin
 
Poscat seminar 2
Poscat seminar 2Poscat seminar 2
Poscat seminar 2
Hyungyu Shin
 
Poscat seminar 1
Poscat seminar 1Poscat seminar 1
Poscat seminar 1
Hyungyu Shin
 

More from Hyungyu Shin (6)

Poscat seminar 9
Poscat seminar 9Poscat seminar 9
Poscat seminar 9
 
Poscat seminar 11
Poscat seminar 11Poscat seminar 11
Poscat seminar 11
 
Poscat seminar 4
Poscat seminar 4Poscat seminar 4
Poscat seminar 4
 
Poscat seminar 3-2
Poscat seminar 3-2Poscat seminar 3-2
Poscat seminar 3-2
 
Poscat seminar 2
Poscat seminar 2Poscat seminar 2
Poscat seminar 2
 
Poscat seminar 1
Poscat seminar 1Poscat seminar 1
Poscat seminar 1
 

Recently uploaded

Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
siemaillard
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
HajraNaeem15
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 

Recently uploaded (20)

Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptxPrésentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
Présentationvvvvvvvvvvvvvvvvvvvvvvvvvvvv2.pptx
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
How to deliver Powerpoint Presentations.pptx
How to deliver Powerpoint  Presentations.pptxHow to deliver Powerpoint  Presentations.pptx
How to deliver Powerpoint Presentations.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 

Poscat seminar 5

  • 1. POSCAT Seminar 5 : Recursion and Divide & Conquer yougatup @ POSCAT 1
  • 2. Topic  Topic today − Recursion • Basic Concept − Divide & Conquer • Basic Concept • Finding Medians • Closest Pair • Implementation POSCAT Seminar 1-2 2 July 2014 yougatup By the way, do you solve all the problems ?
  • 3. You should already know what recursion is ! POSCAT Seminar 1-3 2 July 2014 yougatup
  • 4. Divide & Conquer  Problem Solving Paradigm 1. Break the problem into subproblems : smaller instances 2. Solve them recursively 3. Combine the solutions to get the answer to the problem.  Calculation of time complexity is not trivial − We need Master theorem to calculate it − Recurrence relation − Not that important now POSCAT Seminar 1-4 2 July 2014 yougatup
  • 5. Finding Medians and Selection  Problem Find the k-th smallest element in S, where S is a set of numbers POSCAT Seminar 1-5 2 July 2014 yougatup
  • 6. Finding Medians and Selection  Problem Find the k-th smallest element in S, where S is a set of numbers Naïve approach : Sort it ! O(𝑛 log 𝑛) POSCAT Seminar 1-6 2 July 2014 yougatup
  • 7. Finding Medians and Selection  Problem Find the k-th smallest element in S, where S is a set of numbers Naïve approach : Sort it ! O(𝑛 log 𝑛) Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 ! POSCAT Seminar 1-7 2 July 2014 yougatup
  • 8. Finding Medians and Selection  Problem Find the k-th smallest element in S, where S is a set of numbers Naïve approach : Sort it ! O(𝑛 log 𝑛) Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 ! POSCAT Seminar 1-8 2 July 2014 yougatup
  • 9. Finding Medians and Selection  Problem Find the k-th smallest element in S, where S is a set of numbers Naïve approach : Sort it ! O(𝑛 log 𝑛) Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 ! We have to choose 𝑣 nicely ! … How ? POSCAT Seminar 1-9 2 July 2014 yougatup
  • 10. Finding Medians and Selection  Problem Find the k-th smallest element in S, where S is a set of numbers Naïve approach : Sort it ! O(𝑛 log 𝑛) Divide & Conquer : Choose 𝑣 and split S into 𝑆 𝐿, 𝑆 𝑣, 𝑆 𝑅 ! We have to choose 𝑣 nicely ! … How ? POSCAT Seminar 1-10 2 July 2014 yougatup Randomly !
  • 11. Finding Medians and Selection  Problem If we’re lucky, then the partition goes to small very fast. If not, It will take O(𝑛2 ). Can we trust random choice of 𝑣 ? POSCAT Seminar 1-11 2 July 2014 yougatup
  • 12. Finding Medians and Selection  Problem If we’re lucky, then the partition goes to small very fast. If not, It will take O(𝑛2 ). Can we trust random choice of 𝑣 ? Yes! because the worst case is extremely unlike to occur ! There are 50% chance of being good, that is, the Sublists 𝑆 𝐿 and 𝑆 𝑅 have size at most ¾ of that of S. POSCAT Seminar 1-12 2 July 2014 yougatup
  • 13. Finding Medians and Selection  Problem If we’re lucky, then the partition goes to small very fast. If not, It will take O(𝑛2 ). Can we trust random choice of 𝑣 ? Therefore, the expected running time T(𝑛) is T(𝑛) ≤ T(3𝑛/4) + O(𝑐 ⋅ 𝑛) where 𝑐 is the average number of consecutive splits to find a good split. Clearly 𝑐 = 2. So we can conclude that T(𝑛) = O(𝑛) POSCAT Seminar 1-13 2 July 2014 yougatup
  • 14. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. POSCAT Seminar 1-14 2 July 2014 yougatup
  • 15. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. Brute force approach : Check all pairs of points. O(𝑛2) POSCAT Seminar 1-15 2 July 2014 yougatup
  • 16. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. Divide & Conquer approach 1. Split points into two groups 2. Find closest pair of points for each group 3. Combine the solutions ! POSCAT Seminar 1-16 2 July 2014 yougatup
  • 17. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 1. Split points into two group POSCAT Seminar 1-17 2 July 2014 yougatup
  • 18. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 1. Split points into two group POSCAT Seminar 1-18 2 July 2014 yougatup
  • 19. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 2. Find closest pair of points for each group POSCAT Seminar 1-19 2 July 2014 yougatup
  • 20. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 3. Combine the solutions ? POSCAT Seminar 1-20 2 July 2014 yougatup
  • 21. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 3. Combine the solutions ? POSCAT Seminar 1-21 2 July 2014 yougatup Is it enough to choose small one between two solutions ?
  • 22. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 3. Combine the solutions ? POSCAT Seminar 1-22 2 July 2014 yougatup Is it enough to choose small one between two solutions ? We didn’t consider it
  • 23. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 3. Combine the solutions ? POSCAT Seminar 1-23 2 July 2014 yougatup Then, do we have to consider all the cases when a pair consists of a point in the left and a point in the right ?
  • 24. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. 3. Combine the solutions ? POSCAT Seminar 1-24 2 July 2014 yougatup Then, do we have to consider all the cases when a pair consists of a point in the left and a point in the right ? No! because we have partial solution !
  • 25. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. Idea : If a closer pair is exist, then it must be in the grey region POSCAT Seminar 1-25 2 July 2014 yougatup 𝛿 𝛿 𝛿
  • 26. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. Idea : If a closer pair is exist, then it must be in the grey region POSCAT Seminar 1-26 2 July 2014 yougatup 𝛿 𝛿 𝛿 Still, worst case can happen
  • 27. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. Claim. If 𝑖 − 𝑗 ≥ 12, then the distance between 𝑝𝑖 and 𝑝𝑗 is at least 𝛿 • No two points lie in same 𝛿/2-by-𝛿/2 box. • Two points at least 2 rows apart have distance ≥ 2(𝛿/2) Therefore, it is sufficient to consider 12 points above me ! POSCAT Seminar 1-27 2 July 2014 yougatup
  • 28. Closest pair of points  Problem Given 𝑛 points in the plane, find a pair with smallest Euclidean distance between them. Claim. If 𝑖 − 𝑗 ≥ 12, then the distance between 𝑝𝑖 and 𝑝𝑗 is at least 𝛿 • No two points lie in same 𝛿/2-by-𝛿/2 box. • Two points at least 2 rows apart have distance ≥ 2(𝛿/2) Therefore, it is sufficient to consider 12 points above me ! ∴ T(𝑛) = 2T(𝑛/2) + O(𝑛) = O(𝒏 𝐥𝐨𝐠 𝒏) POSCAT Seminar 1-28 2 July 2014 yougatup