Algorithm is set of steps in an order to solve the particular problem.
Algorithm is step by step solution of the program.
Algorithm is set of specific instructions in order to solve the problem.
Features:
Algorithm should be simple to explain and easy to understand.
It should have finite number of steps.
Algorithm should be in specific order.
Algorithm should provide multiple options with condition.
Advantages of Algorithm
Algorithm is easy to understand as it is written step by step.
User can use their own statements for writing the algorithm.
Before making the program user can check and verify the errors using algorithm.
It is independent of programming language.
It is easy to verify the process because user can easily identify the process using the algorithm.
Example #01:
Write an algorithm to find the sum of two numbers.
Step 1:Start(Begin)
Step 2:insert first number num1
Step 3:insert second number num2
Step 4: add two numbers sum=num1+num2
Step 5:display sum (Print)
Step 6:Stop(End)
Example #02:
Write n algorithm to find the largest among number.
Step 1: Start (Begin)
Step 2: Declare variables a and b.
Step 3: Read variables a and b.
Step 4: If a>b (a is greater than b)
Display a is the largest number.
Else
Display b is the largest number.
Step 5: Stop (End)
FlowChart
Flowchart is a symbolic re-presentation of an algorithm.
Symbols Used-In Flowchart
Many different symbols are used to design and represent the flowchart, For example: Input/Output, decision making, process and connectors has different symbols. Check the table below for symbols that are used in making flowchart.
Flow line | It is used to indicate the flow of logic by connecting symbols. | |
Terminal (Stop/Start) | It is used to represent start and end(stop) of flowchart. | |
Input/Output | Is is used for input and output operation. | |
Processing | It is used for airthmetic operations and data-manipulations. | |
Desicion | It is used to represent the operation in which there are two alternatives, true and false. | |
On-page Connector Off-page Connector | It is used to join different flowline | |
Rules to drawing Flowchart
Understand the problem properly before drawing flowchart.
The flowchart should be followed from top to bottom or left to right using appropriate keywords.
Make sure to start(Begin) it and to stop(End) it.
The flowchart should be clear and easy to understand and follow.
Only standard symbols should be used for making flowcharts.
Only one flow-line should used to connect process or terminals.
Use the direction of arrow to manage the flow of data.
Decision box has two directions True and False.
Short description is required in every symbols to understand the process.
Test the validity of flowchart using testdata.
Advantages of Flowchart
It makes easy to analyze, debug and maintain a program.
Conditions are easy to understand.
It provide better interface for understanding.
It provide appropriate documentation.
Ir re-present the flow of data.
It is easy to identify and maintain/update the process.
Disadvantages of Flowchart
If logic is complex it is difficult to draw a flowchart.
It is difficult to modify/update specially when it requires to redraw.
One should know the meaning of symbols representing flowchart to understand.
Example:
Draw the flowchart to find the sum of two numbers
Draw the flowchart to find the largest among number.
explain underflow and overflow of data.
ReplyDeleteUnderflow means the data provided data in lower the range and overflow means that the value is greater than the max range value for declared data type. for example if the range of a variable of type xy (imaginary) is 10-100. value 8 in underflow and value 110 is overflow.
ReplyDelete