SlideShare a Scribd company logo
7
Most read
13
Most read
15
Most read
CONVEX HULL
Yitian Huang & Zhe Yang
Apr 22, 2016
1
Definition Of Convex HULL
Simply, given a set of points P in a plane, the convex hull of this set is the smallest convex polygon that
contains all points of it.
(A set of points and its convex hull)
2
We will introduce an O(nlogh) algorithm known as Chan’s
Algorithm, where h refers the number of points in the hull.
However, Chan’s Algorithm is based on other two
algorithms known as Jarvis’s Algorithm O(nh) and Graham’s
Algorithm O(nlogn).
So, we will talk about these two algorithms first.
3
Before Start…
• Counterclockwise and Clockwise
• It’s relative
• In this presentation
• Use function orient(p, q, i) to calculate the
relationship of pq and pi.
• Obviously, orient(p, q, i) = - orient(p, i, q)
• Extreme points
• There will be four extreme points
• All of them MUST be in the hull lastly
• Most algorithm choose to start with one of the
extreme points.
• In this presentation
• All algorithms will start will the left most point.
4
Jarvis’s Algorithm
5
Jarvis’s Algorithm
• Perhaps the simplest algorithm for computing Convex Hull
• In the two-dimensional case the algorithm is also known as Jarvis march, after R. A. Jarvis, who
published it in 1973.
• It has a more visual name: ‘Gift Wrapping’.
6
HOW IT WORKS?
1. Start with the left most point, l.
2. Let p = l, find out the point q that
appears to be furthest to the
right to someone standing at p
and looking at other points. (by
comparing all others points)
That’s is: orient(p, q, i) < 0 is always
true for all other points.
3. Set q as p, and use p as the start
point and use the same method
to find the next q.
4. Keep doing step 3, until q is equal
to l.
O(n)
O(h)
Total: O(nh)
O(n)
7
GRAHAM’S ALGORITHM
8
GRAHAM’S ALGORITHM
• It is named after Ronald Graham, who published the original algorithm in 1972.
• Also know as Graham’s scan, first explicitly sorts the points and then scanning algorithm to finish
building the hull.
• Basically, sort + scan.
9
HOW IT WORKS?
1. Start with the left most point, l.
2. Sorts all other points in
counterclockwise order around l.
That’s is: orient(l, i, i+1) > 0 is always
true for all points i.
3. Start with l, let p = l, q = l +1, i = l +
2.
4. Check orient(p, q, i)
• If < 0, move forward, let p = q, q =i, i =
i +1;
• If > 0, remove q, let p = p-1, q = p ;
5. Keep doing step 4, until all points
have been checked.
O(nlogn)
O(n)
Total: O(nlogn)
O(n)
SORTSCAN
10
CHAN’S ALGORITHM
11
Chan’s Algorithm = Jarvis's + Graham’s + ...
• It was discovered by Timothy Chan in 1993.
• It’s a combination of divide-and-conquer, gift-wrapping and graham’s scan.
• it’s output-sensitive, which means its running time depends on the size of its output (or input).
12
HOW IT WORKS?
1. Find a magic value of ‘m’, which
divides all points into n/m subsets,
and each subset has m points,
approximately.
2. To each subset, use Graham’s
algorithm to compute its sub-hull.
3. To all sub-hulls, use Jarvis’s
algorithm to compute the final
convex hull.
• Choose one extreme point as the start
point, and compare the right tangents
of all sub-hulls.
• Choose the rightest one as the next
point.
• Start with the next point, and do it
again, until the next point is equal to
the start point
13
Find Magic ‘m’
• The core of Chan’s algorithm is how to figure out the value of m. (The object is to make m very close to
h, or equal)
• Chan proposed a amazing trick here:
• We set a parameter t = 1 and set m = 2^(2^t).
• Then use this m to execute Chan’s Algorithm, in step 3, we set a counter for the output number of points in the
hull. Once the counter reaches value m, it terminate the algorithm and increment t by 1, re-calculate the value
m, and do it again!
• By doing this, the time for running this algorithm will always be less than O(nlogm).
14
TIME COMPLEXITY
• We divided points into n/m parts, so each part has m
points.
• Since the algorithm will be terminated when it number
of output reaches m, so this step will at most cost
O(nlogm), when m is small.
• For step 2
• It’s O((n/m) * mlogm) = O(nlogm)
• For step 3
• Finding one extreme point, O(n).
• tangents
• Finding the right tangents of one sub-hull, O(logm).
• There are n/m sub-hulls, so O((n/m)logm)
• There are h points in the hull. O(h*(n/m)logm) = O(nlogh)
when h=m.
• Totally, it’s O(nlogh).
1. Find a magic value of ‘m’, which
divides all points into n/m subsets,
and each subset has m points,
approximately.
2. To each subset, use Graham’s
algorithm to compute its sub-hull.
3. To all sub-hulls, use Jarvis’s
algorithm to compute the final
convex hull.
• Choose one extreme point as the start
point, and compare the right tangents
of all sub-hulls.
• Choose the rightest one as the next
point.
• Start with the next point, and do it
again,until the next point is equal to
the start point
15
16
REFERENCES
• [1]. https://en.wikipedia.org/wiki/Chan%27s_algorithm
• [2]. http://tomswitzer.net/2010/12/2d-convex-hulls-chans-algorithm/
• [3]. http://jeffe.cs.illinois.edu/teaching/373/notes/x05-convexhull.pdf
• [4]. http://www.utdallas.edu/~daescu/convexhull.pdf
• [5]. http://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/
• [6]. http://www.geeksforgeeks.org/convex-hull-set-2-graham-scan/
17
THANK YOU!
QUESTIONS?
An example for Gift-wrapping
NOT Chan’s Algorithm!
18

More Related Content

What's hot (20)

Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)
Ridhima Chowdhury
 
Back propagation
Back propagation
Nagarajan
 
Introdution and designing a learning system
Introdution and designing a learning system
swapnac12
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
bankers-algorithm2.pptx
bankers-algorithm2.pptx
jamilmalik19
 
Merge sort algorithm
Merge sort algorithm
srutisenpatra
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
vikas dhakane
 
Learning set of rules
Learning set of rules
swapnac12
 
Data Mining Concepts and Techniques, Chapter 10. Cluster Analysis: Basic Conc...
Data Mining Concepts and Techniques, Chapter 10. Cluster Analysis: Basic Conc...
Salah Amean
 
Conceptual dependency
Conceptual dependency
Jismy .K.Jose
 
Underfitting and Overfitting in Machine Learning
Underfitting and Overfitting in Machine Learning
Abdullah al Mamun
 
Python and Machine Learning
Python and Machine Learning
trygub
 
Adaptive Resonance Theory
Adaptive Resonance Theory
Naveen Kumar
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
Count-Distinct Problem
Count-Distinct Problem
Kai Zhang
 
Advantages and disadvantages of hidden markov model
Advantages and disadvantages of hidden markov model
joshiblog
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
Abhishek Singh
 
Knuth morris pratt string matching algo
Knuth morris pratt string matching algo
sabiya sabiya
 
Convex Hull Algorithms
Convex Hull Algorithms
Kasun Ranga Wijeweera
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 
Knapsack Problem (DP & GREEDY)
Knapsack Problem (DP & GREEDY)
Ridhima Chowdhury
 
Back propagation
Back propagation
Nagarajan
 
Introdution and designing a learning system
Introdution and designing a learning system
swapnac12
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
Gayathri Gaayu
 
bankers-algorithm2.pptx
bankers-algorithm2.pptx
jamilmalik19
 
Merge sort algorithm
Merge sort algorithm
srutisenpatra
 
I. Mini-Max Algorithm in AI
I. Mini-Max Algorithm in AI
vikas dhakane
 
Learning set of rules
Learning set of rules
swapnac12
 
Data Mining Concepts and Techniques, Chapter 10. Cluster Analysis: Basic Conc...
Data Mining Concepts and Techniques, Chapter 10. Cluster Analysis: Basic Conc...
Salah Amean
 
Conceptual dependency
Conceptual dependency
Jismy .K.Jose
 
Underfitting and Overfitting in Machine Learning
Underfitting and Overfitting in Machine Learning
Abdullah al Mamun
 
Python and Machine Learning
Python and Machine Learning
trygub
 
Adaptive Resonance Theory
Adaptive Resonance Theory
Naveen Kumar
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
Count-Distinct Problem
Count-Distinct Problem
Kai Zhang
 
Advantages and disadvantages of hidden markov model
Advantages and disadvantages of hidden markov model
joshiblog
 
0 1 knapsack using branch and bound
0 1 knapsack using branch and bound
Abhishek Singh
 
Knuth morris pratt string matching algo
Knuth morris pratt string matching algo
sabiya sabiya
 
Design & Analysis of Algorithms Lecture Notes
Design & Analysis of Algorithms Lecture Notes
FellowBuddy.com
 

Similar to Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and Zhe Yang (20)

Convex hulls & Chan's algorithm
Convex hulls & Chan's algorithm
Alberto Parravicini
 
Discrete Computaional Geometry
Discrete Computaional Geometry
Saurav Mistry
 
Convex hull
Convex hull
Shiwangi Thakur
 
Unit ii divide and conquer -4
Unit ii divide and conquer -4
subhashchandra197
 
Lecture24
Lecture24
Dr Sandeep Kumar Poonia
 
convexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHulls
convexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHulls
Shanmuganathan C
 
Mba admission in india
Mba admission in india
Edhole.com
 
20 convex hull last 7
20 convex hull last 7
Alexander Decker
 
5.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
A New Approach to Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
A New Approach to Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
Don Sheehy
 
Brute force
Brute force
Sadakathullah Appa College
 
Brute Force and Divide & Conquer Technique
Brute Force and Divide & Conquer Technique
ssusered62011
 
Convex hull in 3D
Convex hull in 3D
Roger Hernando Buch
 
An Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of Points
Kasun Ranga Wijeweera
 
A Tutorial on Computational Geometry
A Tutorial on Computational Geometry
Minh-Tri Pham
 
A sweepline algorithm for Voronoi Diagrams
A sweepline algorithm for Voronoi Diagrams
Sweta Sharma
 
DYNAMIC PROGRAMMING AND GREEDY TECHNIQUE
DYNAMIC PROGRAMMING AND GREEDY TECHNIQUE
ssusered62011
 
LU-17 Closest pair and convex hull using divide and conquer.pptx
LU-17 Closest pair and convex hull using divide and conquer.pptx
AKumaraGuru
 
Lec12
Lec12
faintcardy
 
Discrete Computaional Geometry
Discrete Computaional Geometry
Saurav Mistry
 
Unit ii divide and conquer -4
Unit ii divide and conquer -4
subhashchandra197
 
convexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHulls
convexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHullsconvexHulls
Shanmuganathan C
 
Mba admission in india
Mba admission in india
Edhole.com
 
5.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
5.2 divede and conquer 03
5.2 divede and conquer 03
Krish_ver2
 
A New Approach to Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
A New Approach to Output-Sensitive Voronoi Diagrams and Delaunay Triangulations
Don Sheehy
 
Brute Force and Divide & Conquer Technique
Brute Force and Divide & Conquer Technique
ssusered62011
 
An Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of Points
Kasun Ranga Wijeweera
 
A Tutorial on Computational Geometry
A Tutorial on Computational Geometry
Minh-Tri Pham
 
A sweepline algorithm for Voronoi Diagrams
A sweepline algorithm for Voronoi Diagrams
Sweta Sharma
 
DYNAMIC PROGRAMMING AND GREEDY TECHNIQUE
DYNAMIC PROGRAMMING AND GREEDY TECHNIQUE
ssusered62011
 
LU-17 Closest pair and convex hull using divide and conquer.pptx
LU-17 Closest pair and convex hull using divide and conquer.pptx
AKumaraGuru
 
Ad

More from Amrinder Arora (20)

NP-Completeness - II
NP-Completeness - II
Amrinder Arora
 
Graph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First Search
Amrinder Arora
 
Graph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search Traversal
Amrinder Arora
 
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Amrinder Arora
 
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
Amrinder Arora
 
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Amrinder Arora
 
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Amrinder Arora
 
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
Amrinder Arora
 
Online algorithms in Machine Learning
Online algorithms in Machine Learning
Amrinder Arora
 
NP completeness
NP completeness
Amrinder Arora
 
Algorithmic Puzzles
Algorithmic Puzzles
Amrinder Arora
 
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Amrinder Arora
 
Dynamic Programming - Part II
Dynamic Programming - Part II
Amrinder Arora
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1
Amrinder Arora
 
Greedy Algorithms
Greedy Algorithms
Amrinder Arora
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Amrinder Arora
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1
Amrinder Arora
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
Amrinder Arora
 
Introduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic Notation
Amrinder Arora
 
Set Operations - Union Find and Bloom Filters
Set Operations - Union Find and Bloom Filters
Amrinder Arora
 
Graph Traversal Algorithms - Breadth First Search
Graph Traversal Algorithms - Breadth First Search
Amrinder Arora
 
Graph Traversal Algorithms - Depth First Search Traversal
Graph Traversal Algorithms - Depth First Search Traversal
Amrinder Arora
 
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Bron Kerbosch Algorithm - Presentation by Jun Zhai, Tianhang Qiang and Yizhen...
Amrinder Arora
 
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
Arima Forecasting - Presentation by Sera Cresta, Nora Alosaimi and Puneet Mahana
Amrinder Arora
 
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Stopping Rule for Secretory Problem - Presentation by Haoyang Tian, Wesam Als...
Amrinder Arora
 
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Proof of O(log *n) time complexity of Union find (Presentation by Wei Li, Zeh...
Amrinder Arora
 
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
Proof of Cook Levin Theorem (Presentation by Xiechuan, Song and Shuo)
Amrinder Arora
 
Online algorithms in Machine Learning
Online algorithms in Machine Learning
Amrinder Arora
 
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Euclid's Algorithm for Greatest Common Divisor - Time Complexity Analysis
Amrinder Arora
 
Dynamic Programming - Part II
Dynamic Programming - Part II
Amrinder Arora
 
Dynamic Programming - Part 1
Dynamic Programming - Part 1
Amrinder Arora
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Amrinder Arora
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1
Amrinder Arora
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
Amrinder Arora
 
Introduction to Algorithms and Asymptotic Notation
Introduction to Algorithms and Asymptotic Notation
Amrinder Arora
 
Set Operations - Union Find and Bloom Filters
Set Operations - Union Find and Bloom Filters
Amrinder Arora
 
Ad

Recently uploaded (20)

BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Rajdeep Bavaliya
 
BINARY files CSV files JSON files with example.pptx
BINARY files CSV files JSON files with example.pptx
Ramakrishna Reddy Bijjam
 
How to Manage Inventory Movement in Odoo 18 POS
How to Manage Inventory Movement in Odoo 18 POS
Celine George
 
Overview of Employee in Odoo 18 - Odoo Slides
Overview of Employee in Odoo 18 - Odoo Slides
Celine George
 
How to Manage Multi Language for Invoice in Odoo 18
How to Manage Multi Language for Invoice in Odoo 18
Celine George
 
Unit 3 Poster Sketches with annotations.pptx
Unit 3 Poster Sketches with annotations.pptx
bobby205207
 
Unit- 4 Biostatistics & Research Methodology.pdf
Unit- 4 Biostatistics & Research Methodology.pdf
KRUTIKA CHANNE
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Publishing Your Memoir with Brooke Warner
Publishing Your Memoir with Brooke Warner
Brooke Warner
 
What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
LDMMIA Spring Ending Guest Grad Student News
LDMMIA Spring Ending Guest Grad Student News
LDM & Mia eStudios
 
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
MATERI PPT TOPIK 1 LANDASAN FILOSOFIS PENDIDIKAN
aditya23173
 
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Analysis of Quantitative Data Parametric and non-parametric tests.pptx
Shrutidhara2
 
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
ABCs of Bookkeeping for Nonprofits TechSoup.pdf
TechSoup
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Overview of Off Boarding in Odoo 18 Employees
Overview of Off Boarding in Odoo 18 Employees
Celine George
 
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
SPENT QUIZ NQL JR FEST 5.0 BY SOURAV.pptx
Sourav Kr Podder
 
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
PEST OF WHEAT SORGHUM BAJRA and MINOR MILLETS.pptx
Arshad Shaikh
 
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Paper 109 | Archetypal Journeys in ‘Interstellar’: Exploring Universal Themes...
Rajdeep Bavaliya
 

Convex Hull - Chan's Algorithm O(n log h) - Presentation by Yitian Huang and Zhe Yang

  • 1. CONVEX HULL Yitian Huang & Zhe Yang Apr 22, 2016 1
  • 2. Definition Of Convex HULL Simply, given a set of points P in a plane, the convex hull of this set is the smallest convex polygon that contains all points of it. (A set of points and its convex hull) 2
  • 3. We will introduce an O(nlogh) algorithm known as Chan’s Algorithm, where h refers the number of points in the hull. However, Chan’s Algorithm is based on other two algorithms known as Jarvis’s Algorithm O(nh) and Graham’s Algorithm O(nlogn). So, we will talk about these two algorithms first. 3
  • 4. Before Start… • Counterclockwise and Clockwise • It’s relative • In this presentation • Use function orient(p, q, i) to calculate the relationship of pq and pi. • Obviously, orient(p, q, i) = - orient(p, i, q) • Extreme points • There will be four extreme points • All of them MUST be in the hull lastly • Most algorithm choose to start with one of the extreme points. • In this presentation • All algorithms will start will the left most point. 4
  • 6. Jarvis’s Algorithm • Perhaps the simplest algorithm for computing Convex Hull • In the two-dimensional case the algorithm is also known as Jarvis march, after R. A. Jarvis, who published it in 1973. • It has a more visual name: ‘Gift Wrapping’. 6
  • 7. HOW IT WORKS? 1. Start with the left most point, l. 2. Let p = l, find out the point q that appears to be furthest to the right to someone standing at p and looking at other points. (by comparing all others points) That’s is: orient(p, q, i) < 0 is always true for all other points. 3. Set q as p, and use p as the start point and use the same method to find the next q. 4. Keep doing step 3, until q is equal to l. O(n) O(h) Total: O(nh) O(n) 7
  • 9. GRAHAM’S ALGORITHM • It is named after Ronald Graham, who published the original algorithm in 1972. • Also know as Graham’s scan, first explicitly sorts the points and then scanning algorithm to finish building the hull. • Basically, sort + scan. 9
  • 10. HOW IT WORKS? 1. Start with the left most point, l. 2. Sorts all other points in counterclockwise order around l. That’s is: orient(l, i, i+1) > 0 is always true for all points i. 3. Start with l, let p = l, q = l +1, i = l + 2. 4. Check orient(p, q, i) • If < 0, move forward, let p = q, q =i, i = i +1; • If > 0, remove q, let p = p-1, q = p ; 5. Keep doing step 4, until all points have been checked. O(nlogn) O(n) Total: O(nlogn) O(n) SORTSCAN 10
  • 12. Chan’s Algorithm = Jarvis's + Graham’s + ... • It was discovered by Timothy Chan in 1993. • It’s a combination of divide-and-conquer, gift-wrapping and graham’s scan. • it’s output-sensitive, which means its running time depends on the size of its output (or input). 12
  • 13. HOW IT WORKS? 1. Find a magic value of ‘m’, which divides all points into n/m subsets, and each subset has m points, approximately. 2. To each subset, use Graham’s algorithm to compute its sub-hull. 3. To all sub-hulls, use Jarvis’s algorithm to compute the final convex hull. • Choose one extreme point as the start point, and compare the right tangents of all sub-hulls. • Choose the rightest one as the next point. • Start with the next point, and do it again, until the next point is equal to the start point 13
  • 14. Find Magic ‘m’ • The core of Chan’s algorithm is how to figure out the value of m. (The object is to make m very close to h, or equal) • Chan proposed a amazing trick here: • We set a parameter t = 1 and set m = 2^(2^t). • Then use this m to execute Chan’s Algorithm, in step 3, we set a counter for the output number of points in the hull. Once the counter reaches value m, it terminate the algorithm and increment t by 1, re-calculate the value m, and do it again! • By doing this, the time for running this algorithm will always be less than O(nlogm). 14
  • 15. TIME COMPLEXITY • We divided points into n/m parts, so each part has m points. • Since the algorithm will be terminated when it number of output reaches m, so this step will at most cost O(nlogm), when m is small. • For step 2 • It’s O((n/m) * mlogm) = O(nlogm) • For step 3 • Finding one extreme point, O(n). • tangents • Finding the right tangents of one sub-hull, O(logm). • There are n/m sub-hulls, so O((n/m)logm) • There are h points in the hull. O(h*(n/m)logm) = O(nlogh) when h=m. • Totally, it’s O(nlogh). 1. Find a magic value of ‘m’, which divides all points into n/m subsets, and each subset has m points, approximately. 2. To each subset, use Graham’s algorithm to compute its sub-hull. 3. To all sub-hulls, use Jarvis’s algorithm to compute the final convex hull. • Choose one extreme point as the start point, and compare the right tangents of all sub-hulls. • Choose the rightest one as the next point. • Start with the next point, and do it again,until the next point is equal to the start point 15
  • 16. 16
  • 17. REFERENCES • [1]. https://en.wikipedia.org/wiki/Chan%27s_algorithm • [2]. http://tomswitzer.net/2010/12/2d-convex-hulls-chans-algorithm/ • [3]. http://jeffe.cs.illinois.edu/teaching/373/notes/x05-convexhull.pdf • [4]. http://www.utdallas.edu/~daescu/convexhull.pdf • [5]. http://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/ • [6]. http://www.geeksforgeeks.org/convex-hull-set-2-graham-scan/ 17
  • 18. THANK YOU! QUESTIONS? An example for Gift-wrapping NOT Chan’s Algorithm! 18

Editor's Notes

  • #5: Two concepts