In the example of finding the GCD of two numbers, the inputs are the two numbers, and the result is the GCD.
Often there are several ways to solve a class of problems, several algorithms that will get the job done. The
question then is which algorithm is best? In the case of algorithms for computing, computer scientists have
developed techniques for analyzing the performance and judging the relative quality of different algorithms.
REPRESENTING ALGORITHMS WITH PSEUDOCODE
In computer science, algorithms are usually represented as pseudocode. Pseudocode is close enough to
a real programming language that it can represent the tasks the computer must perform in executing the algorithm.
Pseudocode is also independent of any particular language, and uncluttered by details of syntax, which
characteristics make it attractive for conveying to humans the essential operations of an algorithm.
CHAP. 2] ALGORITHMS 15
Figure 2-1 Staircase dimensions.
CHARACTERIZING ALGORITHMS
To illustrate how different algorithms can have different performance characteristics, we will discuss a
variety of algorithms that computer scientists have developed to solve common problems in computing.
Sequential search
Suppose one is provided with a list of people in the class, and one is asked to look up the name Debbie
Drawe.
Pages:
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51