## No older revisions available

## No older revisions available

# Examples ¶

## BinarySearch ¶

Consider the following problem: one has a directory containing a set of names and a telephone number associated with each name.

The directory is sorted by alphabetical order of names. It contains n entries which are stored in 2 arrays:

names (1..n) ; numbers (1..n)

Given a name and the value n the problem is to find the number associated with the name.

## Closest Set ¶

Input:

P = {p(1), p(2) ,..., p(n) }

where p(i) = ( x(i), y(i) ).

A set of n points in the plane.

Output

The distance between the two points that are closest.

Note: The distance DELTA( i, j ) between p(i) and p(j) is defined by the expression:

Square root of { (x(i)-x(j))^2 + (y(i)-y(j))^2 }

## Integer Multiplication ¶

http://www.csc.liv.ac.uk/~ped/teachadmin/algor/pic4.gif

The (2n)-digit decimal representation of the product x*y = z

Note: The algorithm below works for any number base, e.g. binary, decimal, hexadecimal, etc. We use decimal simply for convenience.

The (2n)-digit decimal representation of the product x*y = z

Note: The algorithm below works for any number base, e.g. binary, decimal, hexadecimal, etc. We use decimal simply for convenience.