Fifth Chapter Lesson-4 Algorithm, flowchart and pseudo code.

At the end of this lesson-

  • 1. You will be able to explain algorithm and flowchart. 
  • 2. You will be able to describe the conditions for writing algorithm. 
  • 3. You will be able to describe the advantages of writing algorithm and flowchart.
  • 4. You will be able to describe the rules of creating flowchart.
  • 5. You will be able to describe the use of symbols used in flowchart. 

 

Algorithm: The word “algorithm” relates to the name of the mathematician Al-khowarizmi, which means a procedure or a technique. Software Engineer commonly uses an algorithm for planning and solving the problems. An algorithm is a sequence of finite number steps to solve a particular problem or algorithm is an ordered set of unambiguous steps that produces a result and terminates in a finite time

Conditions for creating algorithm:

  • 1. Input and output should be defined precisely.
  • 2. Each steps in algorithm should be clear and unambiguous.
  • 3. Algorithm should have finite number of steps to solve a problem.
  • 4. Algorithm should be most effective among many different ways to solve a problem.
  • 5. An algorithm shouldn’t have computer code. Instead, the algorithm should be written in such a way that, it can be used in similar programming languages.

Algorithm has the following characteristics:

Input: An algorithm may or may not require input.
Output: Each algorithm is expected to produce at least one result.
Definiteness: Each instruction must be clear and unambiguous.
Finiteness: If the instructions of an algorithm are executed, the algorithm should terminate after finite number of steps.

Advantages of creating algorithm:

  • 1.It is a step-wise representation of a solution to a given problem, which makes it easy to understand.
  • 2.An algorithm uses a definite procedure.
  • 3.It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge.
  • 4.Every step in an algorithm has its own logical sequence so it is easy to debug.

An algorithm for determining average of two numbers-

  • Step-1: Start
  • Step-2: Input two numbers in variable a & b
  • Step-3: avg = (a+b)/2
  • Step-4: Print the value of avg
  • Step-5: Stop

 

Flowchart: The first design of flowchart goes back to 1945 which was designed by John Von Neumann. Flowchart uses different symbols to design a solution to a problem. In other words, Flowchart is a diagrammatic /graphical representation of an algorithm. Flowchart are very helpful in writing program and explaining program to others. By looking at a Flowchart one can understand the operations and sequence of operations performed in a system. Flowchart is often considered as a blueprint of a design used for solving a specific problem.

Rules of drawing flowchart: 

  • 1.Each flowchart must have only one start and one stop object.
  • 2.The flow of control must always enter an object from the top.
  • 3.The flow of control must always leave an object from the bottom.
  • 4.The conventional symbol should be used to draw a flowchart.
  • 5.Array symbol is used to show the flow of the control.
  • 6.No programming language can be used in drawing flowchart.
  • 7.No matters if symbols become different size but shape should be exact.

Advantages of flowchart:

  • 1. Flowchart is an excellent way of communicating the logic of a program.
  • 2. Easy and efficient to analyze problem using flowchart.
  • 3. During program development cycle, the flowchart plays the role of a blueprint, which makes program development process easier.
  • 4. The flowchart makes program or system maintenance easier.
  • 5. It is easy to convert the flowchart into any programming language code.

Types of flowchart: 

1.System Flowchart: System Flowchart help understand how complex systems work. In system flowchart,input data, process data, store data, print result etc are shown. 

2. Program Flowchart: Program Flowchart is a graphic representation of an algorithm, often used in the design phase of programming to work out the logical flow of a program. It demonstrates how a program works within a system. This flowchart is also used in detecting and correcting errors in a program.

Basic structure of a flowchart:

  • 1.Simple Sequence: In this structure, the instructions of a program are executed in order or sequentially.
  • 2.Selection: This structure is used when instructions are executed based on the condition is true or false.
  • 3.Loop: This structure is used for executing instructions repeatedly until condition is false.
  • 4.Jump: In this structure, control of flow moves to a particular point based on the condition is true or false.

To draw a flowchart following standard symbols are used:

SymbolSymbol NameFunctions
OvalUsed to represent start and end of flowchart.
ParallelogramUsed for input and output
operation.
RectangleProcessing: Used for
arithmetic operations and
data-manipulations
DiamondDecision making. Used to
represent the operation in
which there are two/three
alternatives, true and false
etc
CircleUsed to join different flow line.
ArrowsUsed to indicate the flow of logic by connecting symbols.

 

Flowchart for determining average of two numbers-

 

Pseudo Code:To be pseudo is to be fake. In other words, something that is pseudo is pretending that to be something it’s not. Given this, the term pseudo code makes sense – it isn’t code.

Pseudo code is an informal way of programming description that does not require any strict programming language syntax or underlying technology considerations. It is used for creating an outline or a rough draft of a program. Pseudo code summarizes a program’s flow, but excludes underlying details. System designers write pseudo code to ensure that programmers understand a software project’s requirements and align code accordingly.

Pseudo code is not an actual programming language. So it cannot be compiled into an executable program. It uses short terms or simple English language syntaxes to write code for programs before it is actually converted into a specific programming language. The purpose of using pseudo code is an efficient key principle of an algorithm. It is used in planning an algorithm with sketching out the structure of the program before the actual coding takes place.

Advantages of pseudo code–

  • 1.Pseudo code is understood by the programmers of all types.
  • 2.It enables the programmer to concentrate only on the algorithm part of the code development.
  • 3.It cannot be compiled into an executable program.

Pseudo Code for determining average of two numbers-

  • Start
  • Input a and b
  • avg = (a+b)/2
  • Print avg
  • Stop

Lesson Evaluation-

Knowledge Based Questions:

  • a. What is algorithm?
  • a. What is flowchart?
  • a. What is pseudo code?

Comprehension Based Questions:

  • b.Write down the importance of algorithm in program coding.
  • b.Algorithm is the precondition of coding –explain.
  • b.Explain the symbols used in flowchart.
  • b.Flowchart is symbol based algorithm-explain.
  • b.“It is easy to solve a problem using flowchart than algorithm”-explain.

Creative Questions:

Read the stem and answer the questions:

 

Multiple Choice Questions:

 


Written by,

Leave a Reply

Your email address will not be published. Required fields are marked *