SlideShare a Scribd company logo
1 of 4
Download to read offline
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

Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123Ankita Goyal
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using BacktrackingAbhishek Singh
 
Find Transitive closure of a Graph Using Warshall's Algorithm
Find Transitive closure of a Graph Using Warshall's AlgorithmFind Transitive closure of a Graph Using Warshall's Algorithm
Find Transitive closure of a Graph Using Warshall's AlgorithmSafayet Hossain
 
Topological Sorting
Topological SortingTopological Sorting
Topological SortingShahDhruv21
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms HashingManishPrajapati78
 
THREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREETHREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREESiddhi Shrivas
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search treeChandan Singh
 
Apache web-server-architecture
Apache web-server-architectureApache web-server-architecture
Apache web-server-architectureIvanGeorgeArouje
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structureMAHALAKSHMI P
 
minimization the number of states of DFA
minimization the number of states of DFAminimization the number of states of DFA
minimization the number of states of DFAArchana Gopinath
 
Dbms recovering from a system crash
Dbms recovering from a system crashDbms recovering from a system crash
Dbms recovering from a system crashAbhishek Kumar Gupta
 
Issues in design_of_code_generator
Issues in design_of_code_generatorIssues in design_of_code_generator
Issues in design_of_code_generatorvinithapanneer
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]DEEPIKA T
 
Graph in Data Structure
Graph in Data StructureGraph in Data Structure
Graph in Data StructureProf Ansari
 

What's hot (20)

Sets and disjoint sets union123
Sets and disjoint sets union123Sets and disjoint sets union123
Sets and disjoint sets union123
 
sum of subset problem using Backtracking
sum of subset problem using Backtrackingsum of subset problem using Backtracking
sum of subset problem using Backtracking
 
Find Transitive closure of a Graph Using Warshall's Algorithm
Find Transitive closure of a Graph Using Warshall's AlgorithmFind Transitive closure of a Graph Using Warshall's Algorithm
Find Transitive closure of a Graph Using Warshall's Algorithm
 
Topological Sorting
Topological SortingTopological Sorting
Topological Sorting
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
THREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREETHREADED BINARY TREE AND BINARY SEARCH TREE
THREADED BINARY TREE AND BINARY SEARCH TREE
 
Chapter 12 ds
Chapter 12 dsChapter 12 ds
Chapter 12 ds
 
10.m way search tree
10.m way search tree10.m way search tree
10.m way search tree
 
Apache web-server-architecture
Apache web-server-architectureApache web-server-architecture
Apache web-server-architecture
 
sparse matrix in data structure
sparse matrix in data structuresparse matrix in data structure
sparse matrix in data structure
 
Query trees
Query treesQuery trees
Query trees
 
Queues
QueuesQueues
Queues
 
Classical Planning
Classical PlanningClassical Planning
Classical Planning
 
minimization the number of states of DFA
minimization the number of states of DFAminimization the number of states of DFA
minimization the number of states of DFA
 
Dbms recovering from a system crash
Dbms recovering from a system crashDbms recovering from a system crash
Dbms recovering from a system crash
 
Issues in design_of_code_generator
Issues in design_of_code_generatorIssues in design_of_code_generator
Issues in design_of_code_generator
 
Depth first search [dfs]
Depth first search [dfs]Depth first search [dfs]
Depth first search [dfs]
 
Graph in Data Structure
Graph in Data StructureGraph in Data Structure
Graph in Data Structure
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
Linked list
Linked listLinked list
Linked list
 

Viewers also liked

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 DemonstrationIsmália Santiago
 
Graham Algorithm Demonstration
Graham Algorithm DemonstrationGraham Algorithm Demonstration
Graham Algorithm DemonstrationIsmália Santiago
 
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 classificationYiwei 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 preparationDebbie-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 akorithmeSAT Journals
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processingAhmed Daoud
 

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 Algorithms
Convex Hull AlgorithmsConvex Hull Algorithms
Convex Hull Algorithms
 
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...
 
Convex hull
Convex hullConvex hull
Convex hull
 
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
 

Similar to Convex Hull Algorithm Analysis

01 - DAA - PPT.pptx
01 - DAA - PPT.pptx01 - DAA - PPT.pptx
01 - DAA - PPT.pptxKokilaK25
 
CSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxCSE680-07QuickSort.pptx
CSE680-07QuickSort.pptxDeepakM509554
 
Stochastic Processes Homework Help
Stochastic Processes Homework HelpStochastic Processes Homework Help
Stochastic Processes Homework HelpExcel Homework Help
 
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاقتطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاق
تطبيقات المشتقات والدوال المثلثية و في الحيباة اليويمة و طرق الاشتقاقzeeko4
 
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 1Deepak John
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquerVikas Sharma
 
Class 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptxClass 14 3D HermiteInterpolation.pptx
Class 14 3D HermiteInterpolation.pptxMdSiddique20
 
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.pdffeelinggift
 
Skiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingSkiena algorithm 2007 lecture09 linear sorting
Skiena algorithm 2007 lecture09 linear sortingzukun
 
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 keyappasami
 

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 BehaviorRex Yuan
 
圖文作業
圖文作業圖文作業
圖文作業Rex Yuan
 
A Brief Intro to Chatbot
A Brief Intro to ChatbotA Brief Intro to Chatbot
A Brief Intro to ChatbotRex 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 devicesRex Yuan
 
CSOP 第一週:上課簡報
CSOP 第一週:上課簡報CSOP 第一週:上課簡報
CSOP 第一週:上課簡報Rex Yuan
 
Maximum Flow
Maximum FlowMaximum Flow
Maximum FlowRex Yuan
 
Box Problem
Box ProblemBox Problem
Box ProblemRex Yuan
 
Huffman Code Decoding
Huffman Code DecodingHuffman Code Decoding
Huffman Code DecodingRex Yuan
 
Longest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm AnalysisLongest Common Sequence Algorithm Analysis
Longest Common Sequence Algorithm AnalysisRex 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 ShareRex Yuan
 
計概:Programming Paradigm
計概:Programming Paradigm計概:Programming Paradigm
計概:Programming ParadigmRex 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

Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxgindu3009
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRDelhi Call girls
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...ssifa0344
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...ssuser79fe74
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfSumit Kumar yadav
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Sérgio Sacani
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and ClassificationsAreesha Ahmad
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bSérgio Sacani
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLkantirani197
 
COST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptxCOST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptxFarihaAbdulRasheed
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)Areesha Ahmad
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...RohitNehra6
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...Lokesh Kothari
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxRizalinePalanog2
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsSérgio Sacani
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPirithiRaju
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPirithiRaju
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticssakshisoni2385
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsSumit Kumar yadav
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PPRINCE C P
 

Recently uploaded (20)

Presentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptxPresentation Vikram Lander by Vedansh Gupta.pptx
Presentation Vikram Lander by Vedansh Gupta.pptx
 
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCRStunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
Stunning ➥8448380779▻ Call Girls In Panchshil Enclave Delhi NCR
 
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
TEST BANK For Radiologic Science for Technologists, 12th Edition by Stewart C...
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
 
Chemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdfChemistry 4th semester series (krishna).pdf
Chemistry 4th semester series (krishna).pdf
 
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
Discovery of an Accretion Streamer and a Slow Wide-angle Outflow around FUOri...
 
Bacterial Identification and Classifications
Bacterial Identification and ClassificationsBacterial Identification and Classifications
Bacterial Identification and Classifications
 
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 bAsymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
Asymmetry in the atmosphere of the ultra-hot Jupiter WASP-76 b
 
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRLKochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
Kochi ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Kochi ESCORT SERVICE❤CALL GIRL
 
COST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptxCOST ESTIMATION FOR A RESEARCH PROJECT.pptx
COST ESTIMATION FOR A RESEARCH PROJECT.pptx
 
GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)GBSN - Biochemistry (Unit 1)
GBSN - Biochemistry (Unit 1)
 
Biopesticide (2).pptx .This slides helps to know the different types of biop...
Biopesticide (2).pptx  .This slides helps to know the different types of biop...Biopesticide (2).pptx  .This slides helps to know the different types of biop...
Biopesticide (2).pptx .This slides helps to know the different types of biop...
 
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
GUIDELINES ON SIMILAR BIOLOGICS Regulatory Requirements for Marketing Authori...
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
Pests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdfPests of mustard_Identification_Management_Dr.UPR.pdf
Pests of mustard_Identification_Management_Dr.UPR.pdf
 
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceuticsPulmonary drug delivery system M.pharm -2nd sem P'ceutics
Pulmonary drug delivery system M.pharm -2nd sem P'ceutics
 
Botany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questionsBotany krishna series 2nd semester Only Mcq type questions
Botany krishna series 2nd semester Only Mcq type questions
 
VIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C PVIRUSES structure and classification ppt by Dr.Prince C P
VIRUSES structure and classification ppt by Dr.Prince C P
 

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