You are on page 1of 3

SOFTWARE

Backte
the input record is valid, go
Computer to the routine that computes
scientists look net pay from gross pay.
Repeat these steps for each
for simplicity, employee. Then go to the
speed and routine that prints checks."
Tbe gross-to-net and check-
reliability.

Basics:
writing routines would have
their own algorithms.
Sometimes
they find REALITY INTRUDES
Of course, it isn't quite that
elegance. simple. Ifit were, the study
of algorithms would not

Algorithms
have become a major branch
of computer science and the
subject of countless books
and doctoral theses.
But it's not hard to imag-
ine computer engineers
in the 1950s thinking they
had pretty much finished
the ¡ob. They had invented
memory and other computer stored-program electronic
resources, and are easy to computers, and languages
As the mind
understand and modify. The like Fortran and Cobol to
learns to under-
very best ones are invariably run on them, and they had
stand more complicated largely banished the agony
combinations of ideas, called "elegant," although
Al-Khwarizmi may not have of assembly language pro-
simpler formulae soon gramming. In fact, software
used that term for his for-
reduce their complexity. pioneers such as Grace Hop-
mulas for solving quadratic
- Aittoine-Nicholas per saw compilers, and the
equations.
de Condorcet. 1794 algorithms that instructed
An algorithm can be
thought of as the link be- them, as such an advance-
ment — they could "under-

T
HE WORD algorithm tween the programming
was derived from language and the applica- stand" English — that they
the name Al- tion. It's the way we tell a named the first computer
Khwarizmi, a 9th- Cobol compiler how to gen- to use one the Universal
century Persian mathema- erate a payroll system, for
tician and author of The example.
Compendious Book on Cal- Although algorithms
culation by Completion and can end up as thousands
Balancing. But nowadays of lines of computer code,
the word most often applies they often start as very
to a step-by-step procedure high-level abstractions,
for solving a problem with a the kind an analyst
computer. might hand to a pro-
An algorithm is like grammer.
a recipe, with a discrete For example, a
beginning and end and a lengthy routine in that
prescribed sequence of steps payroll system might
leading unambiguously to have started out with
some desired result. this algorithmic speci-
But coming up with the fication: "Look up the
right answer at the end of a employee's name in
program is only the mini- the Employee Table.
mum requirement. The best Ifit is not there, print
algorithms also run fast, the message, 'Invalid em-
The word algorithm is named after
are sparing in their use of ployee.' If all other data on mathematician Al-Khwarizmi.

30 COMPUTERWORLD MARCH 24,2008


Automatic Computer, or of programs, was knighted
Univac. With adjectives like
"universal" and "automatic" The Quicksort Algorithm in 2000 for his achieve-
ments.
in its name, the computer Another exercise in algo-
could almost be expected to rithms is the famous "trav-
program itself. In the early 1960s, British computer scientist Charles eling salesman problem"
Antony Richard Hoare developed the Quicksort algorithm (TSP), in which a salesman
But in the 1960s, comput- for sorting a list into a sequence. This one is ascending:
ers moved into the business leaves from home to visit a
world in a big way, and soon 1. Pick any element, called a "pivot," from the list. number of cities and wants
two ugly realities intruded. to minimize his distance
2. Pick in turn every other element, comparing each to the traveled. If there are five cit-
The first was the matter of
pivot. If the element is less than the pivot, put it above the ies to visit, there are 60 pos-
"bugs" — a term coined by
pivot. If it is greater, put it below. At the end of that pass sible routes to choose from,
Hopper. Computers made
through the list, the pivot is now in its final correct place. and the obvious algorithm
lots of mistakes because
programmers made lots of 3. In the group of elements ahove the pivot, pick another
is to compute the distances
mistakes. The second was pivot and repeat Step 2. In the group helow the original
for all of them and pick the
sorting, a machine-intensive pivot, pick a third pivot and repeat Step 2. Now three ele-
best one. But the TSP suffers
job that came to dominate, ments have been sorted Into their correct positions.
from an unfortunate phe-
and sometimes overwhelm, nomenon known as "combi-
computing. 4. Repeat the entire process, on successively smaller natorial explosion."
groups, until the whole list is in sequence. If there are 10 cities to vis-
Virtually every major ap-
plication required sorting. Whereas Bubblesort involves moving records very it, there are 1.8 million paths,
For example, if you wanted small distances toward their ftnal resting places, and at 20 cities, the poor
to eliminate duplicate mail- and moving them repeatedly. Quicksort never has to salesman (or his computer)
ings from your customer relocate an element once it is in the right place. has 121 quadrillion routes to
master file, which was sort- -GARY ANTHES consider. Clearly, at some
ed by customer number, you point, the try-them-all algo-
might have had to re-sort rithm becomes impractical.
it by last name within ZIP some of the debugging had By passing through the file So mathematicians and
code. Sorting and merging already been done. But sim- repeatedly and overlapping computer scientists have
big files often went on re- ple ones were often not tbe the pairs, in-sequence rec- come up with all kinds of
peatedly throughout the day. most efficient. They were ords would "bubble up" to ingenious ways to "solve"
Even worse, very few of the not the ones that would the top until eventually the the TSP, which is but one
records being sorted would speed up sorting enough entire file was in sequence. example in a broad class of
fit into those tiny memories, to give the CEO's request a It was easy to understand, important problems. Some
and often they were not same-day turnaround. program and debug, but it algorithms give exact solu-
even on disk; they were on wasn't very efficient because tions for, say, a few hundred
slow, cumbersome magnetic THE SEARCH it required many passes cities or less. But with big-
tapes. When the CEO called FOR ELEGANCE through the file. ger problems, we usually
the data processing shop Computer science took on Descriptions of all the turn to the so-called heu-
and asked, "When can I get these challenges and came clever algorithms that im- ristic algorithms that pro-
that special report?" the DP up with families of algo- proved on Bubblesort would duce "pretty good" but not
guy might have said it would rithms with fancy names fill a book, but many stu- optimal solutions. There is a
take 24 hours because of all like "Induction," "Recursion" dents of algorithms would dizzying assortment of such
the sorting that was needed. and "Divide and Conquer." give the grand-slam award things, including dynamic
So IT people learned that And programmers devel- for elegance to Quicksort, programming, genetic algo-
algorithms mattered. The oped methods (themselves which was invented in the rithms and Markov chains.
choice of algorithm could algorithms) for assessing the early 1960s by Charles Ant- But if you have 1,000 cit-
have a huge effect on both efficiency and general good- ony Richard Hoare, a British ies to visit and you don't
programmability and proc- ness of algorithms. computer scientist. (See box have a Ph.D. in mathematics,
essing efficiency. above.)
A simple sort algorithm you might try the "nearest
If algorithms were simple, called Buhblesort was de- Depending on file size neighbor" algorithm, which
they could be easily coded, veloped early on. It involved and other factors, it can take has proved to be remarkably
debugged and later modi- reading through the file to (Quicksort just seconds to good in many cases. With
fied. Simple ones were less be sorted, looking succes- sort a file that would take this algorithm, at each city,
likely to have bugs in the sively at pairs of adjacent other routines minutes or you simply next travel to the
first place, and if you used records. If they were out of hours to process. Hoare, nearest unvisited city, and
an existing algorithm rather order, the two records in the who also pioneered methods you keep doing that until you
than inventing your own. pair were simply swapped. for proving the correctness have gone to every one. •

MARCH 24, 2008 COMPUTERWORLD 31

You might also like