Class 1+2
Class 1+2
programming an application
Definition of Algorithm
- An algorithm is a step-by-step description to solve a problem.
- An algorithm is a step by step method of solving a problem. It is commonly used for data
processing, calculation and other related computer and mathematical operations.
- An algorithm is also used to manipulate data in various ways, such as inserting a new data
item, searching for a particular item or sorting an item.
2. Example of an algorithm
What is an Algorithm?
A set of rules is a series of instructions that we follow step by step to help us solve a
problem. A simple way to remember a set of rules is using a recipe; we use this example to
put together the cake and wish to follow a certain set of commands to solve our problem.
Algorithms are used by all automated devices to carry out functions. They work by
accepting input and executing all of the commands/steps in the set of rules to get an
output.
In computer programming, algorithms are often formed as functions. These functions serve
as small programs that can be referenced by a larger program. In many cases, there are
several ways to perform a specific operation within a software program. In general term, an
algorithm is defined as a set of instructions designed to perform a specific task. Algorithms
work via input and output. They take the input and apply each step of the algorithm to that
information to produce an output.
Characteristics of a good algorithm are,
Input and output should be defined accurately.
Each step in the algorithm should be clear and unmistakable.
Algorithms should be most effective among many different ways to solve a problem.
An algorithm shouldn't contain computer code. Instead, the algorithm should be
written in such a way that it can be used in different programming languages.
Benefits of algorithm:
Algorithm is a step-wise representation of salutation of problem, which make us familiar
with the problem and decreases its complexity. It makes the task easier to decide on a
specific step. It is easier to start the program with the help of algorithm and also increases
the flexibility of program. Algorithm development process allows and even delivers a
rational study of the solution.
Limitations of algorithm:
Algorithm is not a program, but the concept of what the software should be. Lengthy
development process is time expending and difficult to write. It is difficult to identify each
process and program information.
B. Features
1. An algorithm must be:
+ Definite
+ Finite
+ Precise and Effective
+ Implementation Independent
2. Explain the above four characteristics:
+ Definite:
Before solving a problem, we must know what is the problem about? What we need
to solve it? How many steps we need to do to solve it? Algorithms are created to
solve the complication. We write algorithms to do things we need it to do.
+ Finite:
An algorithms we wrote must be limited, one algorithms solve one problem, many
algorithms solve many progress.
+ Precise and Effective:
An algorithm must work effectively and optimally. When we write algorithms, we will
have to spend a lot of time, I am not mention about when we write wrong code and
have to try again. It must be clear and unambiguous. Each steps should be clear and
its input and output must lead to only one meaning.
+ Implementation Independent:
An algorithm should have step-by-step directions which is should be independent of
any programming code.
Flowchart
Flowchart is the graphical representation of an algorithm. It can be considered as an
implementation of algorithm. A flowchart gives a clear idea about the framework of the
program. Every single step in a flowchart is contained within a shape. These shapes are the
symbols used in a flowchart. The symbols used in flowchart are:
Symbol Name Function
Process Indicates any type of
internal operation inside of
the processor.
Input/output Used for any input/output
(I/O) operation.
Decision Used to ask a question that
can be answered in a binary
format.
Connector Allows the flowchart to be
drawn without intersecting
lines or without a reverse
flow.
Predefined process Used to invoke a subroutine
or an interrupt program.
Terminal Indicates the start or ending
of program, process or
interrupt program.
Flow lines Indicates the direction of
flow of program.
Example of flowchart:
Flowchart to display sum of two numbers.
Compiling process of a computer program/Processes taken from
writing code to execution