Lesson 6 Updated introduction to algorithmic problem solving part 2 of 3 (5)
Lesson 6 Updated introduction to algorithmic problem solving part 2 of 3 (5)
Algorithm can be defined as a general language independent set of actions intended to perform a specific task.
Characteristics of an algorithm:
i. Non – ambiguity / Precise: Each step in an algorithm should be non- ambiguous. i.e each
instruction should be clear and precise.
ii. Finiteness: The algorithm should be finite. The algorithm must be terminated in a
specified time.
iii. Uniqueness: The algorithm must be specified a required output.
iv. Input: Algorithm receives input
v. Output: Algorithm produces output
vi. Generality: The algorithm must work for all set of inputs.
Types of algorithms
CONVENTIONS USED IN WRITING ALGORITHMS
Every algorithm is given a name which reflects the task performed by it.
2. Introductory comments
Task performed by algorithm is described briefly. Any assumptions made by the algorithm are mentioned here along with
variables used and their data types.
3. Steps
It is made up of a sequence of numbered steps each step by step is preceeded by a brief comment describing its function.
If a step is composed of several statements they are executed in a left to right manner.
4. Comments
Can be included within the body or step by step enclosing them in parenthesis.
IMPORTANCE OF ALGORITHMS
It helps in enhancing the thinking process. They are like brain stimulants that will give a boost to our
thinking process.
It helps in solving many problems in computer science, computational biology, and economics.
Without the knowledge of algorithms, we can become a coder but not a programmer.
A good understanding of algorithms will help us to get a job. There is an immense demand of good
programmers in the software industry who can analyse the problem well.
Genetic algorithms and randomized approach will help us to retain that job in the changing market.
Differences between algorithm and computer program
1. Definition
Algorithm: A step-by-step set of instructions or rules designed to solve a specific problem or accomplish a task.
It is abstract and not tied to any specific programming language.
Computer Program: A concrete implementation of one or more algorithms, written in a programming
language, and executed by a computer.
2. Nature
Algorithm: Conceptual, logical, and language-independent. It focuses on the approach and methodology to
solve a problem.
Computer Program: Physical and language-dependent. It is a practical expression of algorithms in code,
meant for execution by computers.
3. Representation
Algorithm: Often represented using pseudocode, flowcharts, or natural language. These are simplified and
focus on logic rather than syntax.
Computer Program: Represented using syntax-specific programming languages like Python, Java, or C++.
4. Purpose
Algorithm: Serves as a blueprint or plan that outlines the steps necessary to solve a problem or perform a task.
Computer Program: Executes the plan laid out by the algorithm to produce tangible results or outputs.
5. Flexibility
Algorithm: Can be applied to various contexts and problems if designed generically. It is independent of
hardware or software environments.
Computer Program: Specific to the environment in which it is implemented and executed, such as operating
systems, libraries, and hardware.
6. Dependency
Algorithm: Exists independently and can be written without knowledge of a programming language or
environment.
Computer Program: Depends on the algorithm as its foundation, but also requires knowledge of programming
languages, tools, and systems for its creation.