ListSearch.gif (446 bytes) Delphi Algorithms

See non-Delphi Algorithms Reference Library page

(bookmark.gif (183 bytes) Bookmark)

general resources Algorithmes (French)
- Introduction to algorithms
- Manipulation of dates
- Math algorithms (e.g., calculating pi)
- Number bases (especially 2, 10 and 16)
- Interpolation using Newton's method
- Soundex Algorithm
- Inversion of matrices
A* Search A* is a search algorithm that  searches from some initial state to a goal state.  It returns the optimum path (list of intermediate states) from the initial state to the goal state. 
Arithmetic See Mathematics
Artificial Intelligence (AI)

NeuroVCL V1.0.  Components for Delphi for building programs with backpropagation neural networks

Program OCR is used for recognition of Cyrillic letters using backpropagation neural networks.

The Inference Engine Component Suite is a Delphi component suite for adding rule-based intelligence to your programs.  This suite provides expert system (rule-based) programming from within the Delphi environment. 

AVL Trees see Trees, AVL
Backgammon In Delphi by Michael J. Mefford in PC Magazine

Ray Lischner's UseNet Post with example of using Pascal sets to define bits.
Tom Backer Johnsen's UseNet Post showing TIntegerSet

Reverse bits in an integer
- UseNet Post by Bruce Roberts (Object Pascal)
- UseNet Post by Sven Pran (assembly)

Freeware ESBMaths with Source. 
- BitsHighest (highest bit set within a LongWord)
- ESBBitsNeeded (number of bits needed to represent a given positive integer)

When Every Bit Counts:  Compact Storage Using Integer Bitfields, Delphi Informant, July 1999.

Delphi Import/Export:  Part II: Streams and Bit Fiddling, in Delphi Informant, July 1998.

Bit Counting (optimized code) 

bookmark.gif (183 bytes)Books

Tomes of Delphi:  Algorithms and Data Structures  US  UK  FR

Ready-to-Run Delphi 3.0 Algorithms
Rod Stephens
John Wiley, 1998

Rod Stephens' web site page about this book

TurboAlgorithms.JPG (6242 bytes) Turbo Algorithms (C, Pascal, Basic, Prolog)
Keith Weiskamp, Namir Shamas, Ron Pronk,
John Wiley, 1989
HandbookOfAlgorithmsGonnet.GIF (7417 bytes) Handbook of Algorithms and Data Structures in Pascal and C
Gaston Gonnet, Ricardo Baeza-Yates
Addison-Wesly, 1991.  (out of print)

Book Web Page:

The Stony Brook Algorithm Repository 

Algorithm Implementations in Pascal

Algorithms by Robert Sedgewick, Older Pascal Version (April 1988).
C Version (April 1992).  C++ Version (January 1999).
Introduction to Algorithms in Pascal by Thomas W. Parsons, John Wiley, 1994.
Boyer-Moore Julian Bucknall discusses text searching using the Boyer-Moore algorithm, showing how it is so much faster than Delphi's built-in Pos function.   Delphi Magazine, Issue 36, August 1998.
Boyer-Moore-Horspool Pattern Match Boyer-Moore-Horspool text searching

Optimized code example

Cards Use Windows CARDS.DLL to build games 

Black Jack Simulator

TCardDeck, including Shuffle method and BlackJack game, in Delphi 5 Developer's Guide by Teixeira and Pacheco



ColorMix.gif (1372 bytes) Color Section of efg's Delphi Graphics Algorithms
(Also see general Color Reference Library page.)
Combinations TCombination class 
Compression Chapter 10, Shannon-Fano, Huffman, LZ77 and LZ78
Introduction to Algorithms in Pascal

Julian Bucknall describes some data compression algorithms, including Huffman encoding.
Delphi Magazine, Issue 44, April 1999

Julian Bucknall takes the lid off Lempel and Ziv’s LZ77 compression algorithm
Delphi Magazine, Issue 45, May 1999

LZW and dynamic Huffman
"Lossless Data Compressions," Byte, March 1991, p. 203

ChiefLZ package uses LZSS and "SixPack" Huffman algorithms. The LZSS low level stuff is in assembler,
but the Huffman stuff is in a plain (and portable) Pascal unit. 

Computational Geometry Tangram 2 puzzle by Gary Darby 

New List Objects:   Delphi 5's New Classes Increase TList Class Abilities 

Convex Hull 
Cryptogrpahy efg's Cryptography page
Cyclic Redundancy Code  (CRC) efg's CRC Lab Report:   Includes code and numerous links to other sites with CRC information, as well as literature sources.
Data Structures & Algorithms EZDSL is a freeware collection of data structures classes for Delphi programmers.  The EZDSL units provide an OOP interface for classical data structures for Delphi: stacks, queues (including deques and priority queues), lists (single, double and skip), hash tables, binary trees (including search and red-black) and so forth.

Data Structures and Algorithms

Dates efg's Dates and Times page


Discrete Math Numerical Methods in Pascal page:  Discrete Math 
Discrete Optimization Methods Discrete Optimization Algorithms with Pascal Programs by Maciej M. Syslo, et al.
Set Cover, Set Packing, Shortest Path, Traveling Salesman Problem, Knapsack Problem, Network Flow, Job Scheduling, Vertex Coloring, Linear Programming, Matching, Minimum Spanning Tree

"Determining the Shortest Path through a Network" by Rod Stephens in December 1998, Delphi Informant, pp. 34-40,

Eight Queens 
Encryption efg's Cryptography page
Endian Robert Lee's UseNet Post assembly code for changing "big endian" to "little endian":   Swap2, Swap4, Swap4Signed, SwapDoubleTo8, Swap8ToDouble

Peter Below's UseNet Post with Swap32 procedure

Martin Harvey's UseNet Post with WordSwap and DWordSwap
efg's Big Endian and Little Endian with floats

Borland's FAQ 1854D, "Big-endian and little-endian formated integers"

Big Endian and Little Endian 

Error Correction Codes Reed-Solomon Error Correction Routines.  Project JEDI Converted Tool by Bruce Christensen. 
Flocking Components for implementing Flocking behavior  

Components for implementing Formations (square, wedge, etc) using flocking behavior. 

Four-Color Mapping A Look at Four- and Five-Color Algorithms, Delphi Informant, May 1999, pp. 40-47

See Four-Color Theorem on Mathematics page

Fractions Numerical Methods in Pascal page:  Fractions 
Fuzzy Logic These three components integrate Fuzzy Logic concepts and could help you to understand Fuzzy Logic with a Stock Fuzzy Management example.

Non-Delphi sites: 

Genetic Algorithms The Genetic Programming component is designed to simplify implementation of a GP System, handling all the GP-specific tasks for the user.
bookmark.gif (183 bytes)Graph Theory

Introducing Graphs.  No, not those pretty things you do on squared paper, but computer science graphs (used, for example, in calculating the smallest distance to drive between appointments in several places). Clever stuff from Julian Bucknall... Delphi Magazine, Issue 32, October 1998

To progress his discussion of graph algorithms Julian Bucknall takes a slight detour to discuss priority queues and how to work with them, handily showing how to implement the heapsort algorithm along the way too.   Delphi Magazine, Issue 39, November 1998

Topological sorts, solving the travelling salesmen problem, the algorithms of Prim and Dijkstra, it’s all here so come join the party...   Delphi Magazine, Issue 41, January 1999

PlanB.  PlanB predstavlja interaktivnu mapu i poslovni imenik Bečeja. Omogućava lako pronalaženje ulica, trgova, firmi i drugih važnijih mesta i objekata na mapi.  http://solair.eunet.yu/~ilicv/PlanB.htm

Graph Theory Lesson 

Graph Traverse

Also see Shortest Paths

Graphics Algorithms efg's Delphi Graphics Algorithms:
General Graphics    Color   Image Processing   Mathematics/Geometry
(also see general Computer Graphics Reference Library page)
Greatest Common Divisor GCD:  Euclid's algorithm in UseNet Post by Hans van Kruijssen
Fibonacci Numbers Numerical Methods in Pascal page:  Prime Numbers, Fibonacci Numbers, Pi
bookmark.gif (183 bytes)Hashing Colin Sarsfield's UseNet Post with HashN function

Making a Hash Of It -- Setting up an Abstract Hash Table, Delphi Informant, Sept. 1999, pp. 31-37. 

Hash It Out:  Using Hash Tables to Manipulate Key-based Data, Delphi Informant, Feb. 1999

Hash-Alogrithm: MD4, MD5, RipeMD160, SHA1, Haval (128-256)


HashTrie is an efficient data structure for fast searching. 

Hash function for strings 

"Hash It Out -- Using Hash Tables to Manipulate Key-based Data"
A hash table is a data structure that allows you to store and retrieve items based on a key.
Delphi Informant, Feb. 1999, pp. 31-37,

How can you find items in a list really quickly? Julian Bucknall knows how to get your data dancing to the right tune and this month begins his explanation of hash tables.   Delphi Magazine, Issue 30, February 1998.

Julian Bucknall concludes his 2-parter exploration of hash tables and how to use them in your Delphi applications to make finding text strings in long lists really quick, plus there’s a natty hash-index record manager ready to plug right into your programs!   Delphi Magazine, Issue 31, March 1998

Brad Stower's UseNet Post about using Windows Atom functions as hash functions

Huffman See Compression
Image Processing efg's Delphi Graphics Algorithms:     Image Processing
(also see general Image Processing Reference Library page)
Interpolation 16-bit Assembly Routine from UseNet Post
Inverse Inverse and n-th roots of large numbers 
Least Common Denominator Borland's "How can I compute the lowest common denominator?"  FAQ 2895D
Hans van Kruijssen UseNet Post
Lightning Nelson Chu Siu Hang's "Ideas Behind My Lightning Effect"
Lists The EZDSL units provide an OOP interface for classical data structures for Delphi: stacks, queues (including deques and priority queues), lists (single, double and skip), hash tables, binary trees (including search and red-black) and so forth. 
bookmark.gif (183 bytes)Lists, Linked

Linked Lists:  When the Data Is Too Dynamic for Arrays, Delphi Informant, May 1998.

Section 6, List Processing with Singly Linked Lists, Turbo Algorithms
Section 7, List Processing with Doubly Linked and Circular Lists, F,

Double linked list, queue, stack

Saving Linked Lists

Map Coloring A Look at Four- and Five-Color Algorithms, Delphi Informant, May 1999, pp. 40-47
Map Projections The MapProject DLL software component library provides functions for transforming vector map data from one map projection to another including changes of datums and spheroids of the earth. 
Maps See Maps on Delphi Graphics Algorithms page
bookmark.gif (183 bytes)Mathematics,
Mathematical Algorithms
math.gif (2730 bytes) Delphi Math Info and Links
Delphi Math Functions
Graphics Math/Geometry

Section 3, Mathematical Algorithms, Turbo Algorithms

Arithmetic Algorithms

Algorithmes mathématiques

(also see general Mathematics Reference Library page)

Mathematics, Recreational Insert + and - signs as necessary into the string 123456789 to form an expression that evaluates to 100
Expressions 100, 

Magic Squares, 

Knight's Tour,'s_tour.htm 

Roman Numerals, 


TCardDeck, including Shuffle method and BlackJack game, in Delphi 5 Developer's Guide by Teixeira and Pacheco

Multiple Precision Arithmetic efg's Cryptography page
N-th Digit Computation 
Neural Networks

NeuralBase -- components library for Delphi Neural Networks 

Artificial Neuronal Network (ANN), which is based on a back propagation algorithm 

Neural Networks

An Introduction to Back-Propagation Neural Networks (Pascal code)

A component with methods for building, train, run,  show ,store, retreive neural nets and is quite easy to use as it  has events for input and output.

Optimization Algorithm Optimization 

See other Optimization links on Miscellany page

Pascal's Triangle Bruce J. Clark's UseNet Post
Permutations TPermutation class 

Permutes 1, 

Pi Optimized code example for calculating pi 

Numerical Methods in Pascal page:  Prime Numbers, Fibonacci Numbers, Pi

Prime Numbers Optimized code example for search for primes 

Prime Factors #1, 

Numerical Methods in Pascal page:  Prime Numbers, Fibonacci Numbers, Pi

Recursion Julian Bucknall gives us the low-down on recursion: what is it, when to use it and when to avoid it, and how to avoid it when you need to!  Delphi Magazine, Issue 35, July 1998

Recursive Structures Search

A beginner's guide to recursion 


Recursion Excursion:  Building an Advanced Expression Calculator article in Delphi Informant

bookmark.gif (183 bytes)Searching

Three Searches:  Delphi Implementations of Classic Techniques  
(Exhaustive, Binary, Interpolative), Delphi Informant, April 1999

Searching Algorithms

Karp-Rabin string search

Sorting and Searching:  A Cookbook 

Boyer-Moore-Horspool text searching

Searching Techniques, Section 2, Turbo Algorithms

Steve Schafer's Usenet Post explaining Binary Tree versus Binary Search

Search SWAG (Software Archive Group):  22 search/find/replace routines,
including Boyer-Moore search (requires Reader)

Also see A*

Selection Selection Algorithms
bookmark.gif (183 bytes)Shortest Path As the Crow Files -- Determining the Shortest Path through a Network, Delphi Informant, December 1998, pp. 34-40 (subscription)

Traveling Salesman Problem program by GrMikeD (updated March 2003)
Link to file at GrMikeD's site

Delphi for Fun:  Shortest Path 

Sieve of Eratosthenes Create list of prime numbers
Simulation and Modeling See Links section of the Delphi Statistics and Probability Library Reference page
See non-Delphi  Simulation & Modeling Library Reference page
bookmark.gif (183 bytes)Sorting Bubble, Selection, Quick Sort Example Using Threads
..\Borland\Delphi n\Demos\Threads\thrddemo.dpr project

Topological Sorting:  Ensuring Things Occur in an Orderly Fashion, Delphi Informant, Oct. 1998.

Sorts of All Types:  Implementing Classic Sort Routines in Delphi (Bubblesort, Selectionsort,        Quicksort, Countingsort) Delphi Informant, Jan 1998.

Sorting and Searching:  A Cookbook 

FindSort unit and demo project by Wellington Lima dos Santos.  (updated 14 Nov 2000)

  1. Sort a Generic Array (CustomArray) by QuickSort algorithm, where
    CustomArray is a variable of type: array[LowIndex..HighIndex] of YourType;

  2. Find an item by binary search algorithm

Julian Bucknall explains sorting algorithms: the good, the bad and the ugly. Get your deck of playing cards out, it’s time for some lab work!  Which is it to be, bubble, shaker, selection, insertion, Shell or quicksort?  Delphi Magazine, Issue 37, September 1998

Julian Bucknall knows that it’s a big wide multilingual world out there and has come up with some clever techniques to ensure that text strings which include all those funny accented, extended and ligature characters always sort correctly.  Delphi Magazine, Issue 27, November 1997

Sorting Algorithms  

Sorting Algorithms  

Fred VonBerg's UseNet Post about Sort List (quicksort)
Philippe Ranger's UseNet Post about sorting TList or TStringList

Sorting Techniques, Section 1, Turbo Algorithms

Sort Solution is a 32-Bit Sort Library with highly optimized and flexible sort algorithms for Windows 95, Windows 98, and Windows NT 4.x.

Download Turbo Pascal 5.5 from the Borland Community Museum:, unpack the DEMOS.ARC file, and look for QSORT.PAS

Sorting SWAG (Software Archive Group):  63 examples   (Requires Reader)

Sources of numeric sorting algorithms:

bookmark.gif (183 bytes)Soundex Algorithm
(phonetic match)
Sounds Gud to Me -- Soundex Encoding, Delphi Informant, March 1998, pp. 34-38.

L'algorithme du SOUNDEX (French)

How to do a "sounds like" query in Interbase,1410,19301,00.html 

Soundex algorithm

Stacks & Queues Section 8, Stacks & Queues, Turbo Algorithms

The EZDSL units provide an OOP interface for classical data structures for Delphi: stacks, queues (including deques and priority queues), lists (single, double and skip), hash tables, binary trees (including search and red-black) and so forth. 

Stony Brook Algorithm Repository Comprehensive collection of algorithm implementations for over seventy of the most fundamental problems in combinatorial algorithms.

Algorithm Implementations in Pascal

String Processing Section 4, String Processing with Word Strings, Turbo Algorithms
Section 5, String Processing with Token Strings, Turbo Algorithms

efg's Strings page

Times efg's Dates and Times page
Tournament  How To Create A Round Robin Tournament Schedule 
Towers of Hanoi 

Traveling salesmen See Graph Theory and Shortest Path
bookmark.gif (183 bytes)Trees Tree Management -- The Care, Feeding, and Implementation of Delphi Trees, Delphi Informant, January 1999, pp. 51-59

Tough Decisions:  Building Delphi Decision Trees, Delphi Informant, June 1998.

Trees, AVL Section 10, AVL-Trees, Turbo Algorithms

UseNet Post with AVL.PAS

Trees, Binary Section 9, Binary Trees, Turbo Algorithms

Steve Schafer's Usenet Post explaining Binary Tree versus Binary Search

Balanced, Binary Trees

The EZDSL units provide an OOP interface for classical data structures for Delphi: stacks, queues (including deques and priority queues), lists (single, double and skip), hash tables, binary trees (including search and red-black) and so forth. 


efg's D4 "Ripple" Project

Leonel Togniolli's "Water Effects" posted to borland.public.attachments

Updated 14 Jun 2009
Since 13 Mar 1999