Our algorithm for designing a set of stairs will be to:
1 Divide the total rise by 7 in and round the result to the nearest whole number to get the number of steps.
2 We will then divide the total run by (the number of steps ??’ 1) (see Fig. 2-1) to compute the run for each step.
3 We will apply one of the formulas to see how close this pair of rise and run parameters is to the ideal.
4 Then we will complete the same computations with one more step and one less step, and also compute the
values of the formula for those combinations of rise and run.
5 We will accept the combination of rise and run that best fits the formula for the ideal.
An algorithm is a way of solving a type of problem, and an algorithm is applicable to many particular
instances of the problem. A good algorithm is a tool that can be used over and over again, as is the case for our
staircase design algorithm.
EXAMPLE??”FINDING THE GREATEST COMMON DENOMINATOR
In mathematics, a famously successful and useful algorithm is Euclid??™s algorithm for finding the greatest
common divisor (GCD) of two numbers. The GCD is the largest integer that will evenly divide the two numbers
in question. Euclid described his algorithm about 300 BCE.
Without having Euclid??™s algorithm, how would one find the GCD of 372 and 84? One would have to factor
the two numbers, and find the largest common factor.
Pages:
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49