Delphi Algorithms

See non-Delphi Algorithms Reference Library page

( 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
http://www.chez.com/algor
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.  www.riversoftavg.com/tastarpathplanner.htm
Arithmetic See Mathematics
Artificial Intelligence (AI)

NeuroVCL V1.0.  Components for Delphi for building programs with backpropagation neural networks
http://solair.eunet.yu/~ilicv/NeuroVCL_eng.html

Program OCR is used for recognition of Cyrillic letters using backpropagation neural networks.
http://solair.eunet.yu/~ilicv/ocr.html

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.
www.riversoftavg.com/inferenceengine.htm

AVL Trees see Trees, AVL
Backgammon In Delphi by Michael J. Mefford in PC Magazine
www.zdnet.com/pcmag/pctech/content/15/20/ut1520.001.html
Backtracking www.ibrtses.com/delphi/backtracking.html
Bits

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.  www.esbconsult.com
- 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)
www.optimalcode.com/exbitcnt.zip

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 www.vb-helper.com/da.htm Turbo Algorithms (C, Pascal, Basic, Prolog) Keith Weiskamp, Namir Shamas, Ron Pronk, John Wiley, 1989 Handbook of Algorithms and Data Structures in Pascal and C Gaston Gonnet, Ricardo Baeza-Yates Addison-Wesly, 1991.  (out of print)Book Web Page: www.dcc.uchile.cl/~rbaeza/handbook/hbook.html The Stony Brook Algorithm Repository www.cs.sunysb.edu/~algorith 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
www.dcc.uchile.cl/~rbaeza/handbook/algs/7/713b.srch.p.html

Optimized code example
www.optimalcode.com/exbmh.zip

Cards Use Windows CARDS.DLL to build games
www.programmersheaven.com/zone2/cat71/14624.htm

Black Jack Simulator

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

Non-Delphi:

Color
 Color Section of efg's Delphi Graphics Algorithms (Also see general Color Reference Library page.)
Combinations TCombination class
www.streamsec.com/combutil.htm
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.
http://website.lineone.net/~african_chief/chieflz3.zip

Computational Geometry Tangram 2 puzzle by Gary Darby
www.delphiforfun.com/Programs/tangram2.htm
Containers

New List Objects:   Delphi 5's New Classes Increase TList Class Abilities
www.delphizine.com/features/2000/12/di200012jm_f/di200012jm_f.asp

Convex Hull http://www.delphiforfun.org/Programs/Fences_and_Traveling_Salesmen.htm
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.
ftp://ftp.turbopower.com/pub/misc/funcs/ezdsl302.exe

www.cs.ncl.ac.uk/people/chris.holt/home.formal/surveying.94-95

Data Structures and Algorithms

Dates efg's Dates and Times page
Dice
Discrete Math Numerical Methods in Pascal page:  Discrete Math
http://www-rab.larc.nasa.gov/nmp/nmpIndex.htm#DiscreteMath
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
www.cs.sunysb.edu/~algorith/implement/syslo/implement.shtml

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

Eight Queens www.delphiforfun.org/Programs/EightQueensPlus.htm
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
www.ftd.fr/odahan/docs/endians.zip

Error Correction Codes Reed-Solomon Error Correction Routines.  Project JEDI Converted Tool by Bruce Christensen.
ftp://delphi-jedi.org//tools/ReedSolomon.zip
Flocking Components for implementing Flocking behavior
www.riversoftavg.com/flocking.htm

Components for implementing Formations (square, wedge, etc) using flocking behavior.  www.riversoftavg.com/formation_flocking.htm

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
http://www-rab.larc.nasa.gov/nmp/nmpIndex.htm#Fractions
Fuzzy Logic These three components integrate Fuzzy Logic concepts and could help you to understand Fuzzy Logic with a Stock Fuzzy Management example.  http://delphi.icm.edu.pl/ftp/d30free/whatsfuz.zip

Non-Delphi sites:
http://fuzzy.sonalysts.com

Genetic Algorithms The Genetic Programming component is designed to simplify implementation of a GP System, handling all the GP-specific tasks for the user.
http://delphi.icm.edu.pl/ftp/d40free/gp.zip
Graph Theory ftp://ftp.ifi.unizh.ch/pub/listen-baeume-graphen/LBG-TEXT

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
www.ftd.fr/odahan/docs/GTL.zip

Graph Traverse
www.delphiforfun.org/Programs/graph_traverse.htm

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

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)
http://delphi.icm.edu.pl/ftp/d20free/cipher.zip

HashTrie is an efficient data structure for fast searching.
http://delphi.icm.edu.pl/ftp/d20free/hashtrie.zip

Hash function for strings
www.scalabium.com/faq/dct0093.htm

"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, di199902rs_f.zip

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
http://xavier.gourdon.free.fr/Constants/Algorithms/inverse.html
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"
www.cs.ust.hk/~cpegnel/lightning.html
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.  http://www.boyet.com/EZDSL/default.htm

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,

www.ibrtses.com/delphi/dllist.html

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.
www.graticule.com/products/mapproject.html
Maps See Maps on Delphi Graphics Algorithms page
Mastermind www.delphiforfun.org/Programs/MasterMind.htm
Mathematics,
Mathematical Algorithms
 Delphi Math Info and Links Delphi Math Functions Graphics Math/Geometry

Section 3, Mathematical Algorithms, Turbo Algorithms

Arithmetic Algorithms
http://www.dcc.uchile.cl/~rbaeza/handbook/arit_a.html

Algorithmes mathématiques
www.chez.com/algor/math/math.htm

(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, www.delphiforfun.org/Programs/Expression100.htm

Magic Squares, www.delphiforfun.org/Programs/magic_squares1.htm

Knight's Tour, www.delphiforfun.org/Programs/knight's_tour.htm

Roman Numerals, www.delphiforfun.org/Programs/roman_numerals.htm

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 http://xavier.gourdon.free.fr/Constants/Algorithms/nthdigit.html
Neural Networks

NeuralBase -- components library for Delphi Neural Networks

Artificial Neuronal Network (ANN), which is based on a back propagation algorithm
http://delphi.icm.edu.pl/ftp/d30share/neuronalnetworktrial.zip

Neural Networks
www.ibrtses.com/delphi/neuralnets.html

An Introduction to Back-Propagation Neural Networks
www.seattlerobotics.org/encoder/nov98/neural.html (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.   http://delphi.icm.edu.pl/ftp/d40share/demoneu4.zip

Optimization Algorithm Optimization
www.optimalcode.com/algrthm.htm

See other Optimization links on Miscellany page

Pascal's Triangle Bruce J. Clark's UseNet Post
Permutations TPermutation class
www.streamsec.com/combutil.htm

Permutes 1, www.delphiforfun.org/Programs/Permutes_1.htm

Pi Optimized code example for calculating pi
www.optimalcode.com/expi.htm

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

Prime Numbers Optimized code example for search for primes
www.optimalcode.com/exprimes.zip

Prime Factors #1, www.delphiforfun.org/Programs/PrimeFactors1.htm

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
www.dcc.uchile.cl/~rbaeza/handbook/search_a.html

A beginner's guide to recursion
www.ftd.fr/odahan/docs/recursion.zip

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

Searching

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

Searching Algorithms
www.dcc.uchile.cl/~rbaeza/handbook/search_a.html

Karp-Rabin string search
www.preview.org/q/q1029.shtml

Sorting and Searching:  A Cookbook
www.ftd.fr/odahan/docs/Sorting.zip

Boyer-Moore-Horspool text searching
www.dcc.uchile.cl/~rbaeza/handbook/algs/7/713b.srch.p.html

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

Also see A*

Selection Selection Algorithms
www.dcc.uchile.cl/~rbaeza/handbook/selec_a.html
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
www.delphiforfun.org/Programs/Fences_and_Traveling_Salesmen.htm

Sieve of Eratosthenes Create list of prime numbers
www.merlyn.demon.co.uk/programs/eratost1.pas
www.merlyn.demon.co.uk/programs/eratost2.pas
www.merlyn.demon.co.uk/programs/eratost3.pas
Simulation and Modeling See Links section of the Delphi Statistics and Probability Library Reference page
See non-Delphi  Simulation & Modeling Library Reference page
Sorting Bubble, Selection, Quick Sort Example Using Threads

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
www.ftd.fr/odahan/docs/Sorting.zip

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

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
www.209software.com/books/p4dp/Sorting.html

Sorting Algorithms
www.dcc.uchile.cl/~rbaeza/handbook/sort_a.html

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.
www.mwlabs.de/psortsol.htm

Download Turbo Pascal 5.5 from the Borland Community Museum:  http://community.borland.com/museum, unpack the DEMOS.ARC file, and look for QSORT.PAS

Sorting SWAG (Software Archive Group):  63 examples

Sources of numeric sorting algorithms:
www.efg2.com/Lab/Library/Delphi/MathFunctions/General.htm#Sorting

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

L'algorithme du SOUNDEX (French)
www.chez.com/algor/soundex/soundex.htm

How to do a "sounds like" query in Interbase
http://community.borland.com/article/0,1410,19301,00.html

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.  http://www.boyet.com/EZDSL/default.htm

Stony Brook Algorithm Repository Comprehensive collection of algorithm implementations for over seventy of the most fundamental problems in combinatorial algorithms.
www.cs.sunysb.edu/~algorith

Algorithm Implementations in Pascal
www.cs.sunysb.edu/~algorith/implement/pascal.shtml

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
www.delphi3000.com/articles/article_1790.asp
Towers of Hanoi
Traveling salesmen See Graph Theory and Shortest Path
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
www.ibrtses.com/delphi/binarytree.html

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. http://www.boyet.com/EZDSL/default.htm

Waves

efg's D4 "Ripple" Project

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

 Updated 14 Jun 2009 Since 13 Mar 1999