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

Algorithms Part 1

Uploaded by

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

Algorithms Part 1

Uploaded by

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

ALGORITHMS PART 1

CHIBI TINODAISHE M
BLUEWAVE ACADEMY DANGAMVURA AREA 3
Definition of an Algorithm:
An algorithm is a step-by-step procedure or sequence of instructions that a computer or a computing
device can execute to solve a specific problem or perform a specific task. It is a precise, finite, and
unambiguous set of operations that transform the input into the desired output.

Characteristics of an Algorithm:
1. Finiteness: An algorithm must terminate after a finite number of steps, producing the desired output.
2. Definiteness: Each step in the algorithm must be precisely defined, with no ambiguity about the
action to be taken.
3. Input: An algorithm must have zero or more inputs, which are the initial values used in the
computation.
4. Output: An algorithm must have one or more outputs, which are the end results of the computation.
5. Effectiveness: An algorithm must be able to be executed effectively, with each step being basic
enough to be carried out in a finite amount of time.

Examples of Algorithms:
1. Sorting Algorithms: Algorithms that arrange a collection of data in a specific order, such as bubble
sort, merge sort, and quicksort.
2. Searching Algorithms: Algorithms that locate a specific item within a collection of data, such as
linear search and binary search.
3. Arithmetic Algorithms: Algorithms that perform basic arithmetic operations, such as addition,
subtraction, multiplication, and division.
4. Pathfinding Algorithms: Algorithms that find the shortest or most optimal path between two points,
such as Dijkstra’s algorithm and the A* algorithm.

Simple Problem and an Algorithm to Solve It:


Let’s consider the problem of finding the maximum of two numbers.

Algorithm:
1. Start.
2. Input two numbers, let’s call them ‘a ‘and ‘b ‘.
3. Compare the values of ‘a ‘and ‘b ‘.
4. If ‘a ‘is greater than or equal to ‘b ‘, set the maximum to ‘a ‘.
5. If ‘b ‘is greater than ‘a ‘, set the maximum to ‘b ‘.
6. Output the maximum value.
7. Stop.

This algorithm takes two numbers as input, compares them, and outputs the maximum value. It is a
simple and straightforward algorithm that can be easily implemented in a programming language.

You might also like