Professional Documents
Culture Documents
Fop XP 02
Fop XP 02
Fop XP 02
Pre-assessment Questions
1. List the types of programming languages.
Ans 2. 0
Ans 3. COBOL
Ans 4. A compiler translates the entire program first and generates the object code, which
can be later executed, whereas an interpreter translates and executes one line of
source code at a time.
Ans 5. FORTRAN was developed in 1957 by John Backus and his team at International
Business Machines (IBM) Corporation.
Objectives
In this lesson, you will learn about:
Introducing Algorithms
• An algorithm is a sequence of steps required to accomplish a task.
Characteristics of an Algorithms
• An algorithm has the following five characteristics:
• An algorithm ends after a fixed number of steps.
• The algorithm should accept input data, in a defined format, before it can be
processed by the given instructions.
Levels of Algorithm
• The two levels of algorithm are:
Representing Algorithms
• Algorithms can be represented in the following different ways:
• Flowcharts
• Decision tables
• Pseudocodes
Flowcharts
• Flowcharts are the graphical representation of algorithms.
• A flowchart consists of symbols, which represent the steps or stages in an
algorithm. Each symbol represents a type of activity.
• The different symbols used in a flowchart are:
• Input/Output
• Process
• Decision
• Procedure/Subroutine
• Flow line
• Start and Stop
• On Page Connector
• Off Page Connector
• Annotation
• Display
Stop
Flowcharts (Contd.)
• The following flowchart displays the greater of two numbers after accepting two
numbers and comparing them.
Start
Stop
Rules of Flowcharting
• American National Standards Institute (ANSI) recommends a number of rules that
need to be followed when drawing flowcharts. Some of these rules and guidelines are
given below:
• The entire logic of a flowchart should be represented using the standard symbols.
• The flowchart should be clear, precise, and easy to follow.
• Flowcharts can have only one start point and one end point.
• The steps in a flowchart should follow top-to-bottom or left-to-right approach.
• All necessary inputs should be listed out in logical order.
• The start and stop symbols should have only a single flow line.
• The input, process, output, and display symbols should have two flow lines
connecting to the previous symbol and to the next symbol.
• The decision symbol should have one flow line connecting to the previous symbol
but two flow lines connecting to the next symbol for each possible solution.
Flowcharts (Contd.)
• Advantages of flowcharts:
• Flowcharts are a better method of communicating logic.
• The flowcharts help in analyzing the problems effectively.
• The flowcharts act as a guide during the program development phase.
• It is easier to debug errors in logic using a flowchart.
• The flowcharts help in maintaining the programs.
Flowcharts (Contd.)
• Disadvantages of flowcharts:
• A lengthy flowchart may extend over multiple pages, which reduces
readability.
• As flowcharts symbols cannot be typed, drawing a flowchart using any graphic
tool is a time consuming process.
• The changes made to a single step may cause redrawing the entire flowchart.
• A flowchart representing a complex algorithm may have too many flow lines.
This reduces readability, and it is time-consuming to draw and understand the
logic Readability.
Decision Tables
• Decision tables represent algorithms that involve complex decision-making.
• A decision table consists of four components, Condition Stub, Condition Applied,
Action Stub, and Action Taken, as shown in the following table :
Decision Table
• Condition Stub
• Consists of the conditions based on which a decision is made.
• Condition Applied
• This component contains the condition alternatives as Y for the satisfied
condition and N for the unsatisfied condition.
• Action Stub
• Contains the actions to be taken for the combination of conditions specified in
the Condition Applied component.
• Action Taken
• Consists of the action alternatives as Y or N. Here, Y or N specify whether or
not the action mentioned in the Action Stub has to be taken.
Pseudocode
• Pseudocode represents an algorithm in English language.
• Pseudocode is used as an alternative to a flowchart.
• The statements used in pseudocode are simple and written in a sequential manner.
• There are a number of keywords used in pseudocode:
• begin…end
• accept
• display
• if…else
Pseudocode (Contd.)
• Advantages of pseudocode
• It is easier and faster to write as compared to a flowchart.
• You can detect errors and make changes to it easily.
• It does not need to be re-written if any changes are made.
• It can be converted to a program using any programming language.
• Disadvantages of pseudocode
• Pseudocode does not provide a graphical representation of an algorithm.
• Pseudocode depicting too many nested conditions may be difficult to
understand
Summary
Inthis lesson, you learned:
• An algorithm is a sequence of steps required to solve a problem.
• Algorithms have two levels, macro and micro.
• Algorithms can be represented in different ways, such as using flowcharts, decision
tables, and pseudocode.
• A flowchart is a graphical representation of the algorithm.
• A decision table is used to depict the decision-making tasks that are involved in a
process.
Summary (Contd.)
• A decision table consists of four components:
• Condition Stub
• Conditions Applied
• Action Stub
• Action Taken
• Pseudocode represents an algorithm in English language.