Looking for Pseudo-code for Fortune's algorithm
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Introduction
Looking for pseudo-code for Fortune's algorithm can be an essential step in understanding the underlying mechanics of constructing Voronoi diagrams efficiently. Fortune's algorithm is a classic computational geometry algorithm optimized for building Voronoi diagrams in time, where is the number of input points. This article provides a detailed exploration of the mechanics of Fortune's algorithm with a focus on pseudo-code and associated explanations for each step.
Fortune's Algorithm: Overview
Fortune's algorithm utilizes a sweep line approach, sweeping a line through the plane and constructing the Voronoi diagram incrementally. The key components include:
- The Sweep Line: A horizontal line that moves from top to bottom.
- The Beach Line: A dynamic parabola arrangement that is the intersection of the sweep line with growing paraboloids centered at each site.
- Event Points: Two kinds of events are processed:
- Site Events: Add a new arc to the beach line.
- Circle Events: Remove arcs from the beach line, creating Voronoi vertices.
Technical Explanation
Key Structures
- Event Queue: A priority queue sorted by the y-coordinate of events. Site events have higher priority if two events share the same y-coordinate.
- Beach Line Status: A balanced tree structure such as a Red-Black tree to maintain the sequence of arcs on the beach line.
- Voronoi Diagram: Dynamically updated as events are processed.
Algorithm Steps
- Initialize the Event Queue with all site events.
- Process Events until the event queue is empty:
- Site Event:
- Determine where the new arc will appear on the beach line.
- Update the beach line and handle intersections.
- Insert potential circle events into the event queue.
- Circle Event:
- Remove the disappearing arc from the beach line and update the Voronoi diagram with a vertex.
- Remove outdated circle events from the queue.
- Complete the Voronoi Diagram by connecting unbounded edges with the convex hull of the original points.
Pseudo-code
Here's the core pseudo-code that defines Fortune's algorithm:
Related reading
- Loop invariant of linear search
- Loop through different sets of unique permutations
- Lossless hierarchical run length encoding
- Lower-bound on comparison-based sorting of n values in the range 1 to k
- Machine Learning Why xWb instead of Wxb?
- Majority element - parts of an array
- LRU cache design
- Luhn or Verhoeff algorithm for credit card numbers

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.