|
My ClickWorld.com | ||||||
|
|
Introduction to AlgorithmComputer programming can be defined as the development of a solution to an identified problem. A programmer starts with a general idea of a task for the computer to perform. Presumably, the programmer has some idea of how to perform the task manually or by hand, at least in general outline. The problem is to flesh out that outline into a complete, unambiguous, step-by-step procedure for carrying out the task. Such a procedure is called an "algorithm." (Technically, an algorithm is an unambiguous, step-by-step procedure developed to describe the process necessary to produce the desired output from a given input. ) An algorithm is not the same as a program. A program is written in some particular programming language. An algorithm is more like the idea behind the program, but it's the idea of the steps the program will take to perform its task, not just the idea of the task itself. The steps of the algorithm don't have to be filled in complete detail, as long as the steps are unambiguous and it's clear that carrying out the steps will accomplish the assigned task. An algorithm can be expressed in any language, including English. Of course, an algorithm can only be expressed as a program if all the details have been filled in. So a program will have input parameters, a process and an out put. Typically, when an algorithm is associated with processing information, data is read from an input source or device, written to an output sink or device, and/or stored for further processing. Stored data is regarded as part of the internal state of the entity performing the algorithm. ![]() As seen in the above diagram the “Process” makes the chunk of the programming activity, and it takes most of the time defining and refining the process. Here we use control and repetitive structures to accomplish this task. For any such computational process, the algorithm must be rigorously defined: specified in the way it applies in all possible circumstances that could arise. That is, any conditional steps must be systematically dealt with, case-by-case; the criteria for each case must be clear and computable. Because an algorithm is a precise list of precise steps, the order of computation will almost always be critical to the functioning of the algorithm. Instructions are usually assumed to be listed explicitly, and are described as starting 'from the top' and going 'down to the bottom', an idea that is described more formally by flow of control. Some History of AlgorithmThe word algorithm comes from the name of the 9th century Persian mathematician Abu Abdullah Muhammad bin Musa al-Khwarizmi. The word algorism originally referred only to the rules of performing arithmetic using Hindu-Arabic numerals but evolved via European Latin translation of al-Khwarizmi's name into algorithm by the 18th century. The word evolved to include all definite procedures for solving problems or performing tasks. The first case of an algorithm written for a computer was Ada Byron's notes on the analytical engine written in 1842, for which she is considered by many to be the world's first programmer. However, since Charles Babbage never completed his analytical engine the algorithm was never implemented on it. PSEUDOCODEAn algorithm represented in pseudocode is a sequence of instructions that can be understood by humans, NOT computers. Example of a pseudocode is given below.
Control StructureIn programming, logic "control structures" are used to define the logic of an algorithm and govern logic flow of program execution. In fact, it has been proved that any programmable algorithm can be coded using only three different control structures, sequence, selection, and repetition. Actually all one needs is the if-then-else for selection and the while loop for repetition. Sequence is the default order of program execution, one instruction after another. Algorithm instructions are executed sequentially UNLESS this is modified by selection or repetition control structures. Selection: this control structure allows the program to choose one of two or more alternative sets of instructions (subtasks). It involves evaluating a "selector", and, depending on its value, deciding which (if any) set of instructions to execute before passing control to the instruction following the selection. The most fundamental form is the if-then-else construct (also called "if-else") which facilitates selection of one of two, mutually exclusive sets (blocks) of instructions. It is the "selection" constructor from which all others can be created. An example of an if-then-else was given above. Repetition: the repetition of a block of instructions may be accomplished two ways: Iteration (or looping), the most common form of repetition in data processing languages, is the cycling through a block of instruction over and over until a condition arises that halts the looping. There are two fundamentally distinct types of loops: Related Articles and News
|
|
||||
|
| ||||||