0% found this document useful (0 votes)
2 views3 pages

Introduction To Algorithm

An algorithm is a systematic procedure for solving a problem or performing a task, akin to a recipe that processes input to produce output. Key characteristics of a good algorithm include input, output, definiteness, finiteness, and effectiveness, with various types such as searching and sorting algorithms. Writing an algorithm involves understanding the problem, identifying steps, and presenting them clearly, which is crucial for efficient programming and problem-solving.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Introduction To Algorithm

An algorithm is a systematic procedure for solving a problem or performing a task, akin to a recipe that processes input to produce output. Key characteristics of a good algorithm include input, output, definiteness, finiteness, and effectiveness, with various types such as searching and sorting algorithms. Writing an algorithm involves understanding the problem, identifying steps, and presenting them clearly, which is crucial for efficient programming and problem-solving.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Introduction to Algorithm

An algorithm is a step-by-step procedure or set of instructions designed to solve a specific


problem or perform a task. It takes some input, processes it through a sequence of steps, and
produces an output.

In simple words, an algorithm is like a recipe — you follow steps to get the final result.

Example (Real Life)

Making tea:

1. Boil water
2. Add tea leaves
3. Add sugar
4. Add milk
5. Stir and serve

This is an algorithm because it follows a sequence of steps.

Characteristics of an Algorithm
A good algorithm has these properties:

1. Input – Takes zero or more inputs


2. Output – Produces at least one output
3. Definiteness – Steps must be clear and unambiguous
4. Finiteness – Must end after a finite number of steps
5. Effectiveness – Each step should be simple and executable

Types of Algorithms (Basic)


1. Searching Algorithms – Find data (e.g., Linear Search)
2. Sorting Algorithms – Arrange data (e.g., Bubble Sort)
3. Recursive Algorithms – Call themselves
4. Divide and Conquer – Break problem into smaller parts
How to Write an Algorithm
When writing an algorithm, follow these steps:

Step 1: Understand the Problem

 What is the input?


 What is the output?

Step 2: Identify Steps

Break the solution into simple steps.

Step 3: Write in Order

Write steps in sequence using numbers.

Step 4: Keep It Simple

Use clear and easy language.

Format of Writing Algorithm


Algorithm Name: (Give a title)

Step 1: Start
Step 2: Input data
Step 3: Process
Step 4: Output result
Step 5: End

Example 1: Algorithm to Add Two Numbers


Algorithm: Add Two Numbers

Step 1: Start
Step 2: Input number1 and number2
Step 3: sum = number1 + number2
Step 4: Display sum
Step 5: End
Example 2: Algorithm to Find Largest
Number
Algorithm: Find Largest Number

Step 1: Start
Step 2: Input A, B
Step 3: If A > B then
Display A is largest
Else
Display B is largest
Step 4: End

Why Algorithms Are Important


 Help in solving problems logically
 Make programming easier
 Improve efficiency
 Used in software, apps, and systems

Conclusion
An algorithm is the foundation of programming. Before writing code, a clear algorithm helps
understand the logic and ensures the solution is correct and efficient.

You might also like