Wolmer’s Trust High School for Girls

CAPE COMPUTER SCIENCE

 

Upper and Lower Six                                           Teacher: Mrs. McCallum-Rodney

 

ALGORITHM

 

OBJECTIVES

 

Students should be able to:

 

1.      explain the concept of an algorithm

2.      identify the necessary properties of algorithms that are well designed

3.      identify ways of representing algorithms

 

INTRODUCTION

 

A computer is an extremely powerful, fast machine.  In less than a second, it can perform difficult calculations that otherwise would take days, months, or years to perform.  Yet a computer has no magical power; it is only a tool.  It cannot devise a plan or decide to act.  It can only do what it is told, in exactly the way it is told.  We can direct the computer to do only what we want by specifying our needs in a discrete step-by-step manner.

 

Specifically, we must develop an algorithm, which is a step-by-step procedure (unambiguous steps) to solve a problem.

 

A computer cannot act independently; it has no intelligence of its own.  For this reason, any algorithm that we use to direct it must be set up to identify all aspects of a processing situation and to present, in detail, all steps to be performed.

 

DEFINITION OF ALGORITHM

 

Solutions to programming problems are formulated as so-called algorithms. An algorithm is a well-defined procedure, consisting of a number of instructions that are executed in turn in order to solve the given problem.

Normally, an algorithm will have certain inputs; for each input, the algorithm should compute an output which is related to the input by a certain so-called input-output relation. Formulating an algorithm makes problem-solving decidedly harder, because it is necessary to formulate very clearly and precisely the procedure for solving the problem. The more general the problem, the harder it gets. The advantage, however, is a much greater understanding of the solution. The process of formulating an algorithm demands a full understanding of why the algorithm is correct.

 PROPERTIES OF ALGORITHMS

·         The properties of an algorithm are:

  1. correctness - To be correct, an algorithm must produce results that are appropriate and complete given any and all sets of appropriate data.
  2. well-designed - Well-designed algorithms are precise and simple.
  3. A general solution to the problem
  4. clearly defined and unambiguous steps
  5. finite number of steps
  6. flow of control from one process to another

 WAYS OF REPRESENTING ALGORITHMS

We can represent algorithms three ways. They are:

 

  1. Narratives
  2. Pseudocodes
  3. Flowcharts

 Narrative

This is a full explanation in natural language on how the system intends to solve the problem.  It gives a structured and systematic explanation of the solution in details.

 

Pseudocode 

Pseudocode is a compact and informal high-level description of a computer programming algorithm that uses the structural conventions of some programming language, but is intended for human reading rather than machine reading.

 

The purpose of using pseudocode is that it is easier for humans to understand than conventional programming language code, and that it is a compact and environment-independent description of the key principles of an algorithm.

 

A pseudocode is an outline of a program, written in a form that can easily be converted into real programming statements.

 

Pseudocode cannot be compiled nor executed, and there are no real formatting or syntax rules. It is simply one step - an important one - in producing the final code. The benefit of pseudocode is that it enables the programmer to concentrate on the algorithms without worrying about all the syntactic details of a particular programming language. In fact, you can write pseudocode without even knowing what programming language you will use for the final implementation.

Flowchart

A flowchart is a diagram showing the structure of a computer program, and the different pathways that can be taken.

A flow chart, or flow diagram, is a graphical representation of a process or system that details the sequencing of steps required to create output. A typical flow chart uses a set of basic symbols to represent various functions, and shows the sequence and interconnection of functions with lines and arrows.

 

A flowchart is a graphical representation of an algorithm. These flowcharts play a vital role in the programming of a problem and are quite helpful in understanding the logic of complicated and lengthy problems. Once the flowchart is drawn, it becomes easy to write the program in any high level language. Often we see how flowcharts are helpful in explaining the program to others. Hence, it is correct to say that a flowchart is a must for the better documentation of a complex program.

 

Flowcharts are usually drawn using some standard symbols:

 The following are some guidelines in flowcharting:

a.   In drawing a proper flowchart, all necessary requirements should be listed out in logical order.

b.  The flowchart should be clear, neat and easy to follow. There should not be any room for ambiguity in understanding the flowchart.

c.  The usual direction of the flow of a procedure or system is from left to right or top to bottom.

d.  Only one flow line should come out from a process symbol.

g.   If the flowchart becomes complex, it is better to use connector symbols to reduce the number of flow lines. Avoid the intersection of flow lines if you want to make it more effective and better way of communication.

 

h.   Ensure that the flowchart has a logical start and finish.

 

i.    It is useful to test the validity of the flowchart by passing through it with a simple test data. 

Make a Free Website with Yola.