0% found this document useful (0 votes)
4 views

Programming Project1

Uploaded by

J Boh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Programming Project1

Uploaded by

J Boh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

2022

Algorithm Programming Project 1


CS 3406-fall 2022
Bohanon, Joyre – Cardwell, Zac – Roberson, Caroline
Contents
Introduction.......................................................................................................................................................................... 2
Empirical Analysis..................................................................................................................................................................2
Brute Force Convex Hull Analysis......................................................................................................................................2
QuickHull Analysis.............................................................................................................................................................3
Visualization of Brute Force Search for Convex Hull Link..................................................................................................4
Visualization of Quickhull Search for Convex Hull Link......................................................................................................4
Outputs................................................................................................................................................................................. 5
Brute Force Output...........................................................................................................................................................5
Quickhull Output...............................................................................................................................................................6
References............................................................................................................................................................................ 7
Introduction
Finding the convex hull of a set of points or objects in 2D space is a relevant topic of observation in that its application
span the subjects of but not limited to mathematics, statistics, optimization, market analysis, and biology. In geometry,
“the convex hull is defined as the smallest convex polygon that encloses a set of points” (Sommer, 2020). In computer
science, writing an efficient algorithm that enables a computer to solve this problem efficiently to a very large set of
elements (e.g., the habitat of rhinoceroses) involves several approaches. The following observations explore the
implementation of a brute force convex hull algorithm and the Quickhull algorithm. The expectation is that the Brute
force implementation will grow at the order of O(n2), and the Quickhull implementation will grow at the order of
O(nlogn).

Empirical Analysis
Both analyses observe the number of operations executed compared to the input size. The input size represents the
number of points (x,y) in 2D space. The approximations are based on the shape/curve of the lines produced from the
number of points searched in relation to the number of operations executed.

Brute Force Convex Hull Analysis

Empirical Analysis of Brute Force Convex Hull


35000000000
f(x) = 25047861.83923 exp( 8.09248279394803E-05 x )
30000000000 R² = 0.56360589246043

25000000000
Operations

20000000000

15000000000

10000000000

5000000000

0
0 20000 40000 60000 80000 100000 120000
Elements (points)

Empirical Analysis of Brute Force Convex Hull


Input Size (n) Count
200 423487
400 1712864
800 6936569
1600 29112236
3200 130127612
6400 584162677
12800 1605522618
25600 1324327517
51200 2095420679
102400 30398084865

These results would indicate that this implementation of the brute force algorithm is closer to an exponential order of
growth which is much slower than the expected quadratic order of growth. Implementation of the algorithm is a large
culprit of the slow down. This implementation is not stable as it will continue to check line segments (point 1 to point 2)
multiple time before searching a new segment. As such, this implementation not only searches every possible
combination of points, but it searches twice. Such repetitive operations result in an increase in the number of basic
operations executed to find the convex hull. This algorithm tries to reduce the number of calculations for the input set
by checking where a point lies relative to the current line segment by skipping points that are the same on either end of
the line segment. It also checks if a single point is found Is not found on the same side. If there is not one the algorithm
stops.

QuickHull Analysis

Empirical Analysis of QuickHull Convex Hull


1200000

1000000 f(x) = 0.000259066334577518 x² + 7.31900894699391 x − 17406.3032946114


R² = 0.985818427502155

800000
Operations

600000

400000

200000

0
0 10000 20000 30000 40000 50000 60000

Elements (points)

Empirical Analysis of QuickHull Convex Hull


Input Size (n) count
200 405
400 805
800 1605
1600 3205
3200 6405
6400 12805
12800 35605
25600 412005
51200 1024005
102400 11782580

These results display a similar decrease in the number of operations executed relative to the input size as was shown in
the brute force search algorithm. However, it is notable that thus algorithm requires significantly less operations to find
the convex hull because this implementation splits the search area in half each iteration instead of searching every
possible combination of points. Although the order of growth was still much much greater than what was expected
(expected O(nlogn)—actual O(n2)), it has been shown that Quickhull is a better implementation for determining the
convex hull of a set of points than that of the brute force implementation.
Visualization of Brute Force Search for Convex Hull Link
https://youtu.be/ep-FX31CpfM

Figure 1 10th pass of brute force approach

Figure 2 Completion of brute force approach

Visualization of Quickhull Search for Convex Hull Link


https://youtu.be/l_n_ZeUZAfk

Figure 3 1st pass of quickhull algorithm and completion


Outputs
Brute Force Output
Quickhull Output
References
Sommer, P. (2020, June 19). A gentle introduction to the convex hull problem. Medium. Retrieved October 13,
2022, from https://medium.com/@pascal.sommer.ch/a-gentle-introduction-to-the-convex-hull-problem-
62dfcabee90c

You might also like