What Is An Algorithm
What Is An Algorithm
An algorithm is a set of commands that must be followed for a computer to perform calculations
or other problem-solving operations.According to its formal definition, an algorithm is a finite
set of instructions carried out in a specific order to perform a particular task. It is not the entire
program or code; it is simple logic to a problem represented as an informal description in the
form of a flowchart or pseudocode.
• Input: After designing an algorithm, the algorithm is given the necessary and desired
inputs.
• Processing unit: The input will be passed to the processing unit, producing the desired
output.
Algorithms are step-by-step procedures designed to solve specific problems and perform tasks
efficiently in the realm of computer science and mathematics. These powerful sets of
instructions form the backbone of modern technology and govern everything from web searches
to artificial intelligence. Here's how algorithms work:
• Input: Algorithms take input data, which can be in various formats, such as numbers,
text, or images.
• Processing: The algorithm processes the input data through a series of logical and
mathematical operations, manipulating and transforming it as needed.
• Output: After the processing is complete, the algorithm produces an output, which
could be a result, a decision, or some other meaningful information.
Scalability
It aids in your understanding of scalability. When you have a sizable real-world problem, you
must break it down into small steps to analyze it quickly.
Performance
The real world is challenging to break down into smaller steps. If a problem can be easily divided
into smaller steps, it indicates that the problem is feasible.
After understanding what is an algorithm, why you need an algorithm, you will look at how to
write one using an example.
Types of Algorithms
3. Hashing Algorithm: Converts data into a fixed-size hash value, enabling rapid data
access and retrieval in hash tables, commonly used in databases and password
storage.
4. Divide and Conquer Algorithm: Breaks a complex problem into smaller subproblems,
solves them independently, and then combines their solutions to address the original
problem effectively.
5. Greedy Algorithm: Makes locally optimal choices at each step in the hope of finding a
global optimum, useful for optimization problems but may not always lead to the best
solution.
• There are no well-defined standards for writing algorithms. It is, however, a problem
that is resource-dependent. Algorithms are never written with a specific programming
language in mind.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 4: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 6: Stop
Step 1: Start
Step 4: If a > b
If a > c
Else
Else
If b > c
Else
Step 5: Stop
• Reproducibility: They yield consistent results when provided with the same inputs.
• Scalability: Many algorithms can handle larger datasets and scale with increasing input
sizes.
• Automation: They enable automation of tasks, reducing the need for manual
intervention.
Disadvantages of Algorithms:
• Limitations: Some problems may not have efficient algorithms, leading to suboptimal
solutions.
Properties of algorithm.
1. 1) Input
There are more quantities that are extremely supplied.
2. 2) Output
At least one quantity is produced.
3. 3) Definiteness
Each instruction of the algorithm should be clear and unambiguous.
4. 4) Finiteness
The process should be terminated after a finite number of steps.
5. 5) Effectiveness
Every instruction must be basic enough to be carried out theoretically or by using paper
and pencil.