SlideShare a Scribd company logo
Convex Hull Algorithm Analysis
Rex Yuan
March 29, 2015
Brute Force Approach
The most naive brute force approach to the convex hull problem iterates over
all points three time. First two iterations yield all possible lines formed by the
points, and the last iteration checks all points against all lines. If a pair of point
(p1, p2) satisfies the condition that all other points are in the same side from
p1p2, we confirm that (p1, p2) are two of the most outer points, and thus are of
the convex hull.
Pseudo Code
Algorithm 1 Convex Hull Brute Force Algorithm
procedure ConvexHullBF(Points)
results = []
for all p1 in Points do
for all p2 in Points do
for all p3 in Points do
Currentside ← side point3 is on respecting p1p2
if side not defined then
side ← Currentside
else if Currentside = side then
side ← False
break
end if
end for
if side = False then
append p1 and p2 to results
end if
end for
end for
end procedure
1
Time Complexity
The worst total operations of naive brute force algorithm takes three iterations
over n point, which is approximately 3n3
which is O(n3
).
Divide and Conquer Approach
The divide and conquer approach takes a collection of points, Points, and a pair
of two points (Rp, Lp) which are the rightmost and leftmost points in Points,
regarding x axis. Next, find the furthest point Furthestp from RpLp, and
divide Points into four parts with LpFurp and RpFurp. Then, recurse left
with (Lp, Furp) and the left/down portion of Points and right with (Furp, Rp)
and the right/up portion of Points.
Pseudo Code for Main Algorithm
Algorithm 2 Convex Hull Divide and Conquer Algorithm
results = []
function DC(Rp, Lp, Points)
if Points is empty then base case
return Θ(1)
end if
Furp ← Furp(RpLp, Points) Θ(n)
Lps, Rps ← LR(RpLp, FurpLp, RpFurp, Points) Θ(n)
append Furp to results Θ(1)
DC(Lp, Furp, Lps)
DC(Furp, Rp, Rps)
end function
procedure ConvexHullDC(results)
Rightp, Leftp ← rightmost and leftmost points in input, regarding x axis
Ups ← points in the upper sections of line RightpLeftp
Los ← points in the Lower sections of line RightpLeftp
DC(Rightp, Leftp, Ups)
DC(Rightp, Leftp, Los)
end procedure
The algorithm(Furp) to calculate furthest point takes a line(p1p2) and a col-
lection of point(ps), and then iterates through ps to find the point with furthest
distance from p1p2 in ps and return that point(result). The algorithm(LR)
to find left/right sections takes three lines(p1p2, p1p3, p2p3) and a collection
of points(ps) and use the slope(m) to find the appropriate left/right sections.
It then iterates over ps to find two collections of points(leftps, rightps), corre-
sponding to left/right sections of ps and return leftps and rightps
2
Pseudo Code for Helper Functions
Algorithm 3 Furthest Point in ps from p1p2
function Furp(p1p2, ps)
result = None, furd = 0
for all p in ps do
if Dist(p, p1p2) > furd then
furd ← Dist(p, p1p2)
result ← p
end if
end for
end function
Algorithm 4 Left and Right Sections of ps
function LR(p1p2, p1p3, p2p3, ps)
leftps = []
rightps = []
left ← check the slope(m) of p1p2, p1p3, p2p3 to find out how is ps
divided, and then decide which is the left side
right ← check the slope(m) of p1p2, p1p3, p2p3 to find out how is ps
divided, and then decide which is the right side
for all p in ps do
if p in left then
append p to leftps
else if p in right then
append p to rightps
end if
end for
return leftps, rightps
end function
Divide and Conquer Approach Analysis
The recurrence of the worst case of the divide and conquer approach is
T(n) = 2T(
n
2
) + O(n)
because every recursion call takes about 2n+1 operations which is O(n), and for
the two subsequent recursion calls it makes, the worst case would be no points
were eliminated in that call, so the sum of two subsequent inputs is still n. An
example of this of this would be when input points form a circle, making the
two subsequent input n
2 .
According to Master Method, this is Case 1(a = bd
). Thus, O(nlogn).
3
Input points form a hollow circle:no points will be eliminated in all calls.
Data Structure
In the actual implementation, I used the dictionary type in Python. With keys
representing index number of a point and its content a tuple of the coordinates
of that point.
{index : (x coordinate, y coordinate)}
Run Time Comparison
I created the following table using UNIX POSIX time function and round the
mean time of 10 trials to five digits after decimal point to calculate the time
past for either brute force and divide and conquer method.
Table 1: Multi-column table
Run Time Comparison(s)
Sample Brute Force Divide and Conquer
1 0.18544 0.00115
2 1.14565 0.00237
3 > 300 0.22048
4 > 300 24.31725
4

More Related Content

What's hot

Convex hull
Convex hullConvex hull
Convex hull
Shiwangi Thakur
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
Dattatray Gandhmal
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problems
Sampath Kumar S
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
Vicente García Díaz
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
hodcsencet
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
Jothi Lakshmi
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
Shubham Dwivedi
 
Quick Sort
Quick SortQuick Sort
Quick Sort
Shweta Sahu
 
Randomized Algorithm
Randomized AlgorithmRandomized Algorithm
Randomized Algorithm
Kanishka Khandelwal
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
Ratnakar Mikkili
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
FellowBuddy.com
 
Quick sort
Quick sortQuick sort
Quick sort
Jehat Hassan
 
Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithnKumar
 
Randomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced AlgorithmRandomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced Algorithm
Mahbubur Rahman
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
kanikkk
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
United International University
 

What's hot (20)

Convex hull
Convex hullConvex hull
Convex hull
 
Recognition-of-tokens
Recognition-of-tokensRecognition-of-tokens
Recognition-of-tokens
 
2.8 normal forms gnf & problems
2.8 normal forms   gnf & problems2.8 normal forms   gnf & problems
2.8 normal forms gnf & problems
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
unit-4-dynamic programming
unit-4-dynamic programmingunit-4-dynamic programming
unit-4-dynamic programming
 
LR PARSE.pptx
LR PARSE.pptxLR PARSE.pptx
LR PARSE.pptx
 
Merge sort
Merge sortMerge sort
Merge sort
 
Dag representation of basic blocks
Dag representation of basic blocksDag representation of basic blocks
Dag representation of basic blocks
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Heaps
HeapsHeaps
Heaps
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
Randomized Algorithm
Randomized AlgorithmRandomized Algorithm
Randomized Algorithm
 
Regular expressions
Regular expressionsRegular expressions
Regular expressions
 
Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}Heuristic Search Techniques {Artificial Intelligence}
Heuristic Search Techniques {Artificial Intelligence}
 
Quick sort
Quick sortQuick sort
Quick sort
 
Convex Hull Algorithms
Convex Hull AlgorithmsConvex Hull Algorithms
Convex Hull Algorithms
 
Quick sort algorithn
Quick sort algorithnQuick sort algorithn
Quick sort algorithn
 
Randomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced AlgorithmRandomized Algorithm- Advanced Algorithm
Randomized Algorithm- Advanced Algorithm
 
simple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilonsimple problem to convert NFA with epsilon to without epsilon
simple problem to convert NFA with epsilon to without epsilon
 
Type Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLikeType Checking(Compiler Design) #ShareThisIfYouLike
Type Checking(Compiler Design) #ShareThisIfYouLike
 

Viewers also liked

convex hull
convex hullconvex hull
convex hull
Aabid Shah
 
Convex hulls & Chan's algorithm
Convex hulls & Chan's algorithmConvex hulls & Chan's algorithm
Convex hulls & Chan's algorithm
Alberto Parravicini
 
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
 
Jarvis Algorithm Demonstration
Jarvis Algorithm DemonstrationJarvis Algorithm Demonstration
Jarvis Algorithm Demonstration
Ismália Santiago
 
Approximation de ritter
Approximation de ritterApproximation de ritter
Approximation de ritter
Mag-Stellon Nadarajah
 
Graham Algorithm Demonstration
Graham Algorithm DemonstrationGraham Algorithm Demonstration
Graham Algorithm Demonstration
Ismália Santiago
 
26 Computational Geometry
26 Computational Geometry26 Computational Geometry
26 Computational Geometry
Andres Mendez-Vazquez
 
Svm V SVC
Svm V SVCSvm V SVC
Svm V SVC
AMR koura
 
An Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of PointsAn Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of PointsKasun Ranga Wijeweera
 
View classification of medical x ray images using pnn classifier, decision tr...
View classification of medical x ray images using pnn classifier, decision tr...View classification of medical x ray images using pnn classifier, decision tr...
View classification of medical x ray images using pnn classifier, decision tr...
eSAT Journals
 
How to use SVM for data classification
How to use SVM for data classificationHow to use SVM for data classification
How to use SVM for data classification
Yiwei Chen
 
Basic guide to turf cricket pitch preparation
Basic guide to turf cricket pitch preparationBasic guide to turf cricket pitch preparation
Basic guide to turf cricket pitch preparation
Debbie-Ann Hall
 
project presentation on mouse simulation using finger tip detection
project presentation on mouse simulation using finger tip detection project presentation on mouse simulation using finger tip detection
project presentation on mouse simulation using finger tip detection Sumit Varshney
 
Mri brain image segmentatin and classification by modified fcm &svm akorithm
Mri brain image segmentatin and classification by modified fcm &svm akorithmMri brain image segmentatin and classification by modified fcm &svm akorithm
Mri brain image segmentatin and classification by modified fcm &svm akorithm
eSAT Journals
 
Svm my
Svm mySvm my
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
Ahmed Daoud
 
morphological image processing
morphological image processingmorphological image processing
morphological image processingJohn Williams
 
Image Classification And Support Vector Machine
Image Classification And Support Vector MachineImage Classification And Support Vector Machine
Image Classification And Support Vector MachineShao-Chuan Wang
 

Viewers also liked (20)

convex hull
convex hullconvex hull
convex hull
 
convex hull
convex hullconvex hull
convex hull
 
Convex hulls & Chan's algorithm
Convex hulls & Chan's algorithmConvex hulls & Chan's algorithm
Convex hulls & Chan's algorithm
 
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 ...
 
Jarvis Algorithm Demonstration
Jarvis Algorithm DemonstrationJarvis Algorithm Demonstration
Jarvis Algorithm Demonstration
 
Approximation de ritter
Approximation de ritterApproximation de ritter
Approximation de ritter
 
Graham Algorithm Demonstration
Graham Algorithm DemonstrationGraham Algorithm Demonstration
Graham Algorithm Demonstration
 
Lec12
Lec12Lec12
Lec12
 
26 Computational Geometry
26 Computational Geometry26 Computational Geometry
26 Computational Geometry
 
Svm V SVC
Svm V SVCSvm V SVC
Svm V SVC
 
An Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of PointsAn Efficient Convex Hull Algorithm for a Planer Set of Points
An Efficient Convex Hull Algorithm for a Planer Set of Points
 
View classification of medical x ray images using pnn classifier, decision tr...
View classification of medical x ray images using pnn classifier, decision tr...View classification of medical x ray images using pnn classifier, decision tr...
View classification of medical x ray images using pnn classifier, decision tr...
 
How to use SVM for data classification
How to use SVM for data classificationHow to use SVM for data classification
How to use SVM for data classification
 
Basic guide to turf cricket pitch preparation
Basic guide to turf cricket pitch preparationBasic guide to turf cricket pitch preparation
Basic guide to turf cricket pitch preparation
 
project presentation on mouse simulation using finger tip detection
project presentation on mouse simulation using finger tip detection project presentation on mouse simulation using finger tip detection
project presentation on mouse simulation using finger tip detection
 
Mri brain image segmentatin and classification by modified fcm &svm akorithm
Mri brain image segmentatin and classification by modified fcm &svm akorithmMri brain image segmentatin and classification by modified fcm &svm akorithm
Mri brain image segmentatin and classification by modified fcm &svm akorithm
 
Svm my
Svm mySvm my
Svm my
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
morphological image processing
morphological image processingmorphological image processing
morphological image processing
 
Image Classification And Support Vector Machine
Image Classification And Support Vector MachineImage Classification And Support Vector Machine
Image Classification And Support Vector Machine
 

Similar to Convex Hull Algorithm Analysis

01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
KokilaK25
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptx
DeepakM509554
 
Stochastic Processes Homework Help
Stochastic Processes Homework HelpStochastic Processes Homework Help
Stochastic Processes Homework Help
Excel Homework Help
 
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاقتطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
zeeko4
 
Stochastic Processes Homework Help
Stochastic Processes Homework HelpStochastic Processes Homework Help
Stochastic Processes Homework Help
Statistics Homework Helper
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
Nehagupta259541
 
Geometric algorithms
Geometric algorithmsGeometric algorithms
Geometric algorithms
Ganesh Solanke
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
Deepak John
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
Nv Thejaswini
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
Vikas Sharma
 
Class 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptxClass 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptx
MdSiddique20
 
In three of the exercises below there is given a code of a method na.pdf
In three of the exercises below there is given a code of a method na.pdfIn three of the exercises below there is given a code of a method na.pdf
In three of the exercises below there is given a code of a method na.pdf
feelinggift
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingzukun
 
1. Random walk.pdf
1. Random walk.pdf1. Random walk.pdf
1. Random walk.pdf
Anjali Devi J S
 
26 Computational Geometry
26 Computational Geometry26 Computational Geometry
26 Computational Geometry
Andres Mendez-Vazquez
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
appasami
 
Computer Network Assignment Help
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
Computer Network Assignment Help
 

Similar to Convex Hull Algorithm Analysis (20)

01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptx
 
Slide2
Slide2Slide2
Slide2
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptx
 
Stochastic Processes Homework Help
Stochastic Processes Homework HelpStochastic Processes Homework Help
Stochastic Processes Homework Help
 
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاقتطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
 
Stochastic Processes Homework Help
Stochastic Processes Homework HelpStochastic Processes Homework Help
Stochastic Processes Homework Help
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
Geometric algorithms
Geometric algorithmsGeometric algorithms
Geometric algorithms
 
Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1Anlysis and design of algorithms part 1
Anlysis and design of algorithms part 1
 
Unit 3 daa
Unit 3 daaUnit 3 daa
Unit 3 daa
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Class 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptxClass 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptx
 
In three of the exercises below there is given a code of a method na.pdf
In three of the exercises below there is given a code of a method na.pdfIn three of the exercises below there is given a code of a method na.pdf
In three of the exercises below there is given a code of a method na.pdf
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sorting
 
Randomization
RandomizationRandomization
Randomization
 
1. Random walk.pdf
1. Random walk.pdf1. Random walk.pdf
1. Random walk.pdf
 
algorithm Unit 3
algorithm Unit 3algorithm Unit 3
algorithm Unit 3
 
26 Computational Geometry
26 Computational Geometry26 Computational Geometry
26 Computational Geometry
 
Cs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer keyCs6402 design and analysis of algorithms may june 2016 answer key
Cs6402 design and analysis of algorithms may june 2016 answer key
 
Computer Network Assignment Help
Computer Network Assignment HelpComputer Network Assignment Help
Computer Network Assignment Help
 

More from Rex Yuan

8/9 RLDM for Prosocial Behavior
8/9 RLDM for Prosocial Behavior8/9 RLDM for Prosocial Behavior
8/9 RLDM for Prosocial Behavior
Rex Yuan
 
圖文作業
圖文作業圖文作業
圖文作業
Rex Yuan
 
A Brief Intro to Chatbot
A Brief Intro to ChatbotA Brief Intro to Chatbot
A Brief Intro to Chatbot
Rex Yuan
 
A review of consumer brain computer interface devices
A review of consumer brain computer interface devicesA review of consumer brain computer interface devices
A review of consumer brain computer interface devices
Rex Yuan
 
CSOP 第一週:上課簡報
CSOP 第一週:上課簡報CSOP 第一週:上課簡報
CSOP 第一週:上課簡報
Rex Yuan
 
Maximum Flow
Maximum FlowMaximum Flow
Maximum Flow
Rex Yuan
 
Box Problem
Box ProblemBox Problem
Box Problem
Rex Yuan
 
Huffman Code Decoding
Huffman Code DecodingHuffman Code Decoding
Huffman Code Decoding
Rex Yuan
 
Longest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm AnalysisLongest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm Analysis
Rex Yuan
 
計概:Programming Paradigm (Notes)
計概:Programming Paradigm (Notes)計概:Programming Paradigm (Notes)
計概:Programming Paradigm (Notes)
Rex Yuan
 
台灣大學聯盟第一學期
台灣大學聯盟第一學期台灣大學聯盟第一學期
台灣大學聯盟第一學期
Rex Yuan
 
Word and Phrases: Improv Everywhere - Gotta Share
Word and Phrases: Improv Everywhere - Gotta ShareWord and Phrases: Improv Everywhere - Gotta Share
Word and Phrases: Improv Everywhere - Gotta Share
Rex Yuan
 
計概:Programming Paradigm
計概:Programming Paradigm計概:Programming Paradigm
計概:Programming Paradigm
Rex Yuan
 
LinkedIn, the Serious Network 繁體中文版
LinkedIn, the Serious Network  繁體中文版LinkedIn, the Serious Network  繁體中文版
LinkedIn, the Serious Network 繁體中文版
Rex Yuan
 

More from Rex Yuan (14)

8/9 RLDM for Prosocial Behavior
8/9 RLDM for Prosocial Behavior8/9 RLDM for Prosocial Behavior
8/9 RLDM for Prosocial Behavior
 
圖文作業
圖文作業圖文作業
圖文作業
 
A Brief Intro to Chatbot
A Brief Intro to ChatbotA Brief Intro to Chatbot
A Brief Intro to Chatbot
 
A review of consumer brain computer interface devices
A review of consumer brain computer interface devicesA review of consumer brain computer interface devices
A review of consumer brain computer interface devices
 
CSOP 第一週:上課簡報
CSOP 第一週:上課簡報CSOP 第一週:上課簡報
CSOP 第一週:上課簡報
 
Maximum Flow
Maximum FlowMaximum Flow
Maximum Flow
 
Box Problem
Box ProblemBox Problem
Box Problem
 
Huffman Code Decoding
Huffman Code DecodingHuffman Code Decoding
Huffman Code Decoding
 
Longest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm AnalysisLongest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm Analysis
 
計概:Programming Paradigm (Notes)
計概:Programming Paradigm (Notes)計概:Programming Paradigm (Notes)
計概:Programming Paradigm (Notes)
 
台灣大學聯盟第一學期
台灣大學聯盟第一學期台灣大學聯盟第一學期
台灣大學聯盟第一學期
 
Word and Phrases: Improv Everywhere - Gotta Share
Word and Phrases: Improv Everywhere - Gotta ShareWord and Phrases: Improv Everywhere - Gotta Share
Word and Phrases: Improv Everywhere - Gotta Share
 
計概:Programming Paradigm
計概:Programming Paradigm計概:Programming Paradigm
計概:Programming Paradigm
 
LinkedIn, the Serious Network 繁體中文版
LinkedIn, the Serious Network  繁體中文版LinkedIn, the Serious Network  繁體中文版
LinkedIn, the Serious Network 繁體中文版
 

Recently uploaded

Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Sérgio Sacani
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
fafyfskhan251kmf
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
sanjana502982
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
muralinath2
 
ESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptxESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptx
PRIYANKA PATEL
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
pablovgd
 
What is greenhouse gasses and how many gasses are there to affect the Earth.
What is greenhouse gasses and how many gasses are there to affect the Earth.What is greenhouse gasses and how many gasses are there to affect the Earth.
What is greenhouse gasses and how many gasses are there to affect the Earth.
moosaasad1975
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
University of Maribor
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
University of Maribor
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
IshaGoswami9
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
HongcNguyn6
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
kejapriya1
 
Unveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdfUnveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdf
Erdal Coalmaker
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
Columbia Weather Systems
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
Renu Jangid
 
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills MN
 
Chapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisisChapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisis
tonzsalvador2222
 
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptxThe use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
MAGOTI ERNEST
 
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Ana Luísa Pinho
 

Recently uploaded (20)

Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...
 
Deep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless ReproducibilityDeep Software Variability and Frictionless Reproducibility
Deep Software Variability and Frictionless Reproducibility
 
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdfDMARDs Pharmacolgy Pharm D 5th Semester.pdf
DMARDs Pharmacolgy Pharm D 5th Semester.pdf
 
Toxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and ArsenicToxic effects of heavy metals : Lead and Arsenic
Toxic effects of heavy metals : Lead and Arsenic
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
 
ESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptxESR spectroscopy in liquid food and beverages.pptx
ESR spectroscopy in liquid food and beverages.pptx
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
 
What is greenhouse gasses and how many gasses are there to affect the Earth.
What is greenhouse gasses and how many gasses are there to affect the Earth.What is greenhouse gasses and how many gasses are there to affect the Earth.
What is greenhouse gasses and how many gasses are there to affect the Earth.
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
 
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
Comparing Evolved Extractive Text Summary Scores of Bidirectional Encoder Rep...
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
 
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốtmô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
mô tả các thí nghiệm về đánh giá tác động dòng khí hóa sau đốt
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
 
Unveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdfUnveiling the Energy Potential of Marshmallow Deposits.pdf
Unveiling the Energy Potential of Marshmallow Deposits.pdf
 
Orion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWSOrion Air Quality Monitoring Systems - CWS
Orion Air Quality Monitoring Systems - CWS
 
Leaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdfLeaf Initiation, Growth and Differentiation.pdf
Leaf Initiation, Growth and Differentiation.pdf
 
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
Travis Hills' Endeavors in Minnesota: Fostering Environmental and Economic Pr...
 
Chapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisisChapter 12 - climate change and the energy crisis
Chapter 12 - climate change and the energy crisis
 
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptxThe use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
The use of Nauplii and metanauplii artemia in aquaculture (brine shrimp).pptx
 
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
Deep Behavioral Phenotyping in Systems Neuroscience for Functional Atlasing a...
 

Convex Hull Algorithm Analysis

  • 1. Convex Hull Algorithm Analysis Rex Yuan March 29, 2015 Brute Force Approach The most naive brute force approach to the convex hull problem iterates over all points three time. First two iterations yield all possible lines formed by the points, and the last iteration checks all points against all lines. If a pair of point (p1, p2) satisfies the condition that all other points are in the same side from p1p2, we confirm that (p1, p2) are two of the most outer points, and thus are of the convex hull. Pseudo Code Algorithm 1 Convex Hull Brute Force Algorithm procedure ConvexHullBF(Points) results = [] for all p1 in Points do for all p2 in Points do for all p3 in Points do Currentside ← side point3 is on respecting p1p2 if side not defined then side ← Currentside else if Currentside = side then side ← False break end if end for if side = False then append p1 and p2 to results end if end for end for end procedure 1
  • 2. Time Complexity The worst total operations of naive brute force algorithm takes three iterations over n point, which is approximately 3n3 which is O(n3 ). Divide and Conquer Approach The divide and conquer approach takes a collection of points, Points, and a pair of two points (Rp, Lp) which are the rightmost and leftmost points in Points, regarding x axis. Next, find the furthest point Furthestp from RpLp, and divide Points into four parts with LpFurp and RpFurp. Then, recurse left with (Lp, Furp) and the left/down portion of Points and right with (Furp, Rp) and the right/up portion of Points. Pseudo Code for Main Algorithm Algorithm 2 Convex Hull Divide and Conquer Algorithm results = [] function DC(Rp, Lp, Points) if Points is empty then base case return Θ(1) end if Furp ← Furp(RpLp, Points) Θ(n) Lps, Rps ← LR(RpLp, FurpLp, RpFurp, Points) Θ(n) append Furp to results Θ(1) DC(Lp, Furp, Lps) DC(Furp, Rp, Rps) end function procedure ConvexHullDC(results) Rightp, Leftp ← rightmost and leftmost points in input, regarding x axis Ups ← points in the upper sections of line RightpLeftp Los ← points in the Lower sections of line RightpLeftp DC(Rightp, Leftp, Ups) DC(Rightp, Leftp, Los) end procedure The algorithm(Furp) to calculate furthest point takes a line(p1p2) and a col- lection of point(ps), and then iterates through ps to find the point with furthest distance from p1p2 in ps and return that point(result). The algorithm(LR) to find left/right sections takes three lines(p1p2, p1p3, p2p3) and a collection of points(ps) and use the slope(m) to find the appropriate left/right sections. It then iterates over ps to find two collections of points(leftps, rightps), corre- sponding to left/right sections of ps and return leftps and rightps 2
  • 3. Pseudo Code for Helper Functions Algorithm 3 Furthest Point in ps from p1p2 function Furp(p1p2, ps) result = None, furd = 0 for all p in ps do if Dist(p, p1p2) > furd then furd ← Dist(p, p1p2) result ← p end if end for end function Algorithm 4 Left and Right Sections of ps function LR(p1p2, p1p3, p2p3, ps) leftps = [] rightps = [] left ← check the slope(m) of p1p2, p1p3, p2p3 to find out how is ps divided, and then decide which is the left side right ← check the slope(m) of p1p2, p1p3, p2p3 to find out how is ps divided, and then decide which is the right side for all p in ps do if p in left then append p to leftps else if p in right then append p to rightps end if end for return leftps, rightps end function Divide and Conquer Approach Analysis The recurrence of the worst case of the divide and conquer approach is T(n) = 2T( n 2 ) + O(n) because every recursion call takes about 2n+1 operations which is O(n), and for the two subsequent recursion calls it makes, the worst case would be no points were eliminated in that call, so the sum of two subsequent inputs is still n. An example of this of this would be when input points form a circle, making the two subsequent input n 2 . According to Master Method, this is Case 1(a = bd ). Thus, O(nlogn). 3
  • 4. Input points form a hollow circle:no points will be eliminated in all calls. Data Structure In the actual implementation, I used the dictionary type in Python. With keys representing index number of a point and its content a tuple of the coordinates of that point. {index : (x coordinate, y coordinate)} Run Time Comparison I created the following table using UNIX POSIX time function and round the mean time of 10 trials to five digits after decimal point to calculate the time past for either brute force and divide and conquer method. Table 1: Multi-column table Run Time Comparison(s) Sample Brute Force Divide and Conquer 1 0.18544 0.00115 2 1.14565 0.00237 3 > 300 0.22048 4 > 300 24.31725 4