Introduction
In this lecture, we apply the Brute Force (BF) design technique to geometric problems. Two major case studies are discussed:
-
Closest Pair of Points – finding the two points that are nearest in a 2D plane.
-
Convex Hull – finding the smallest convex polygon that encloses all points.
These problems appear in air-traffic control, pattern recognition, GIS mapping, image analysis, and bioinformatics.
Table of Contents
-
Overview of Brute Force in Geometry
-
Problem 1: Closest Pair of Points
-
Problem Statement
-
Brute Force Algorithm
-
Example and Explanation
-
Applications
-
-
Problem 2: Convex Hull Problem
-
Definition and Key Concepts
-
Brute Force Convex Hull Algorithm
-
Applications of Convex Hull
-
Complexity Comparison
-
-
Conclusion
Overview of Brute Force in Geometry
The Brute Force approach tests all possible combinations to find an optimal geometric result.
While it’s conceptually simple and widely applicable, its time complexity is high (O(n²)–O(n³)).
Despite inefficiency, brute force helps in:
-
Understanding geometric relationships.
-
Validating optimized algorithms (e.g., Divide & Conquer, Graham Scan).
-
Handling small or pre-sorted datasets effectively.
Problem 1: Closest Pair of Points
Problem Statement
Given a set of n points in 2D space, find the two points that are closest to each other in terms of Euclidean distance.
distance(pi,pj)=(xi−xj)2+(yi−yj)2
Brute Force Algorithm
ALGORITHM BruteForceClosestPair(P)
// Input: List P of n points (xi, yi)
// Output: Minimum distance between two pointsmin_dist ← ∞for i ← 0 to n−2 do
for j ← i+1 to n−1 do
d ← sqrt((x[i] − x[j])² + (y[i] − y[j])²)
if d < min_dist then
min_dist ← d
return min_dist
Time Complexity: O(n²)
Space Complexity: O(1)
Example and Explanation
Consider points:
P = {(2, 3), (4, 1), (5, 4), (1, 2)}
Compute distance between all pairs:
(2,3)-(4,1) = 2.82
(2,3)-(5,4) = 3.16
(2,3)-(1,2) = 1.41 ✅
...
Closest pair = (2,3) & (1,2), distance = 1.41
Applications
-
Air-Traffic Control: Find two closest aircraft in space.
-
Cluster Analysis: Identify similar data points for grouping.
-
Face Recognition: Measure Euclidean distance between facial feature vectors.
-
Bioinformatics: Compare DNA sequences by similarity metrics.
Problem 2: Convex Hull Problem
Definition and Key Concepts
Definition:
Given a set Q of n points in 2D, find the smallest convex polygon P that encloses all points.
-
Convex Set: For any two points p, q ∈ S, the entire line segment pq lies in S.
-
Convex Polygon: A polygon where all interior angles < 180°.
-
Extreme Points: Points that lie on the outer boundary of the set (cannot be expressed as combinations of others).
Brute Force Convex Hull Algorithm
Idea:
A line segment joining two points (pi, pj) is part of the convex hull if and only if all other points lie on the same side of that line.
ALGORITHM BruteForceConvexHull(P)
// Input: List P of n points (xi, yi)
// Output: Points forming the convex hullfor i ← 0 to n−2 dofor j ← i+1 to n−1 do
compute a, b, c from (Pi, Pj)
same_side ← true
for k ← 0 to n−1 where k ≠ i,j do
s ← a*x[k] + b*y[k] − c
check sign consistency
if all points on same side
mark (Pi, Pj) as hull edge
return hull edges
Where
a=y2−y1,b=x1−x2,c=x1y2−y1x2
Time Complexity: O(n³)
Space Complexity: O(1)
Applications of Convex Hull
| Field | Application |
|---|---|
| Computer Graphics | Surface approximation & triangulation |
| Image Processing | Hand contour detection for gesture recognition |
| GIS Mapping | Define boundary of a geographic dataset |
| Machine Learning | Feature clustering & outlier detection |
Complexity Comparison
| Problem | Brute Force | Optimized Alternative |
|---|---|---|
| Closest Pair | O(n²) | Divide & Conquer – O(n log n) |
| Convex Hull | O(n³) | Graham Scan / Jarvis March – O(n log n) |
Conclusion
The Brute Force technique offers a direct but computationally expensive way to solve geometric problems like Closest Pair and Convex Hull.
Although these algorithms are not efficient for large data, they help in conceptual understanding and validation of optimized solutions. Here is complete lecture Lecture # 15_new