0% found this document useful (0 votes)
5 views

What Is An Algorithm

Uploaded by

akramshaik2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

What Is An Algorithm

Uploaded by

akramshaik2004
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

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.

• Problem: A problem can be defined as a real-world problem or real-world instance


problem for which you need to develop a program or set of instructions. An algorithm is
a set of instructions.

• Algorithm: An algorithm is defined as a step-by-step process that will be designed for a


problem.

• 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.

• Output: The outcome or result of the program is referred to as the output.


How do Algorithms Work?

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.

• Efficiency: A key aspect of algorithms is their efficiency, aiming to accomplish tasks


quickly and with minimal resources.

• Optimization: Algorithm designers constantly seek ways to optimize their algorithms,


making them faster and more reliable.

• Implementation: Algorithms are implemented in various programming languages,


enabling computers to execute them and produce desired outcomes.

What is the Need for Algorithms?

You require algorithms for the following reasons:

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

1. Searching Algorithm: Designed to find a specific target within a dataset, enabling


efficient retrieval of information from sorted or unsorted collections.

2. Sorting Algorithm: Aimed at arranging elements in a specific order, like numerical or


alphabetical, to enhance data organization and retrieval.

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.

How to Write an Algorithm?

• 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.

Algorithm 1: Add two numbers entered by the user

Step 1: Start
Step 2: Declare variables num1, num2 and sum.

Step 3: Read values num1 and num2.

Step 4: Add num1 and num2 and assign the result to sum.

sum←num1+num2

Step 5: Display sum

Step 6: Stop

Algorithm 2: Find the largest number among three numbers

Step 1: Start

Step 2: Declare variables a,b and c.

Step 3: Read variables a,b and c.

Step 4: If a > b

If a > c

Display a is the largest number.

Else

Display c is the largest number.

Else

If b > c

Display b is the largest number.

Else

Display c is the greatest number.

Step 5: Stop

Advantage and Disadvantages of Algorithms


Advantages of Algorithms:

• Efficiency: Algorithms streamline processes, leading to faster and more optimized


solutions.

• Reproducibility: They yield consistent results when provided with the same inputs.

• Problem-solving: Algorithms offer systematic approaches to tackle complex problems


effectively.

• 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:

• Complexity: Developing sophisticated algorithms can be challenging and time-


consuming.

• Limitations: Some problems may not have efficient algorithms, leading to suboptimal
solutions.

• Resource Intensive: Certain algorithms may require significant computational


resources.

• Inaccuracy: Inappropriate algorithm design or implementation can result in incorrect


outputs.

• Maintenance: As technology evolves, algorithms may require updates to stay relevant


and effective.

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.

You might also like