Using a computer to solve a problem frequently requires programming, the formulation of a plan for precisely defined actions to be performed by the computer to obtain the solution to the problem. Such a plan is an algorithm. In this chapter, we introduce a helpful method for solving a problem with a computer. We also show ways of breaking up a problem into smaller sub-problems. Of course, in this introductory chapter we will consider only some simple problems, such as the computation of part of a weekly payroll. Algorithms are plans for performing actions.
Common examples of algorithm are:
DIRECTIONS FOR GETTING SOMEWHERE:
Directions for getting to Fred's pizza parlor1. Take Route 116 until you come to the T-junction at Route 9.
2. Turn onto Route 9 and go about three quarters of a mile and it will be on our left. You can't miss it.
A COOKIE RECIPE:
Cream HornsRoll out thinly puff or flaky pastry into an oblong approximately 12 inches long, and cut into 1-inch strips. Moisten one edge of each strip and roll the strip around a cream horn tin, starting at the pointed end of the tin and overlapping the pastry very slightly. Bake in a hot oven until crisp 10 - 15 minutes. Slip the horns off the tins. When they are cold, fill them with whipped cream and dredge with confectioners sugar.
A CROCHET PATTERN:
Raw 2 (afgham st): 1 sc in first dc, (draw up loop in next st and retain loop on hook) 5 times (6 loops on hook), draw up loop in next st and draw this loop thru 1st loop on hook forming an upright st on bar (yo and thru 2 loops) 5 times. There are 6 bars and 1 loop on hook. Retain loops on hook and draw up loop in each o next 5 bars 96 loops on hook) draw up loop in next stand thru first loop on hook (yo and thru 2 loops0 5 times. Rep from twice.Insert hook in 2nd bar, yo and thru bar and loop on hook (1st bound off). Bind off 4 more sts, 1 sc in next sc Rep from, ending bind off 5sts, sl st in top of turning ch. Ch 1, turn.
These algorithms require varying degrees of technical knowledge in order for someone to carry them out, or execute them. The first algorithm is expressed in a language that almost everybody can understand. The second requires some knowledge of pastry making to understand, While the third requires considerable experience with crocheting and reading crochet patterns.
There is also a difference in the level of detail provided in each algorithm, the first is at a high level and provides almost no detail, Whereas the third is at a low level and provides much detail. The making of each individual is defined. Algorithms for use on computers are called program and can be expressed at varying levels of detail. In this chapter, we will consider several examples of representations of simple algorithms.
Programming languages are methods for representing and communicating algorithms, both to people and to computers. As with the algorithms we just viewed, different programming languages provide varying levels of detail. We will be mainly concerned with languages convenient for people, referred to as high level programming languages. A low level programming language that expresses an algorithm in terms of it's primitive operations is so full of small details like the crocheting pattern that is difficult for people to understand. Luckily, computers can easily translate an algorithm expressed in a high level programming language into a low level computer language. In this chapter, we will present a payroll program of a few different languages to provide an insight into the similarities and differences among programming languages.
No comments:
Post a Comment