Algorithms

Example of iterative operation

0. set response <- yes
1. repeat until response is no

2.   read gallons_used, starting_mileage, ending_mileage

3.   distance_driven <- ending_mileage -starting_mileage

4.   average-miles_per_gallon <- distance-driven ÷ gallons_used

5.   write average_miles_per_gallon > 25.0 then

6.   if average_miles_per_gallon > 25.0 then

7.       write 'You are getting good gas mileage.'

8.   else

9.      write 'You are not getting good gas mileage.'

10.  write 'Do you want to do this again, yes or no?'

11.  read response

12. stop

COMPUTING FIBONACCI NUMBERS

THE BUBBLE SORT

THE SELECT SORT

BINARY SEARCH

[Prev][TOC]


CS1104 Main Page
Last Updated 2001/06/10
© L.Heath, 2000, upgraded by J.A.N. Lee, 2001.