Delphi Programming

An algorithm is a finite list of well-defined instructions for accomplishing some task/problem, for example searching for a string in another string, sorting a set of strings or returning the highest number from an array.

There are a lot of different algorithms for accomplishing the same or different tasks and all of them have different benefits. One algorithm could do something very fast using much memory, and another can do the same thing slower using less memory.

Here comes a list of well know/used algorithms with an comment so you get the basic idea of what it does.

A List of Algorithms[]

Searching Algorithms[]

(list of string searches from Wikipedia)

Algorithm Preprocessing time Matching time
Knuth-Morris-Pratt algorithm Θ(m) Θ(n)
Rabin-Karp algorithm Θ(m) average Θ(n+m),
worst Θ(n m)
Finite state automaton based search Θ(m |Σ|) Θ(n)
Boyer-Moore string search algorithm Θ(m + |Σ|) Ω(n/m), O(n)
Bitap algorithm (shift-or, shift-and, Baeza-Yates-Gonnet) Θ(m + |Σ|) Θ(n)

Sorting Algorithms[]

Algorithm Description
Binary tree sort
Bubble sort A very slow algorithm for sorting a list. Other sorts are better in nearly all cases. See QuickSort (but beware: Quicksort is not a stable sorting algorithm, that is, it may change the order of items that have got the same key, while Bubble sort is stable)
Cocktail sort
Comb sort
Gnome sort
In-place merge sort
Insertion sort
Library sort
Merge sort
Patience sorting
Radix sort
Selection sort
Shaker sort
Shell sort

External links[]